[[email protected] ~]# kubectl get namespace #查看名称空间
NAME STATUS AGE
default Active 9h
kube-node-lease Active 9h
kube-public Active 9h
kube-system Active 9h
[[email protected]~]#
[[email protected]~]# kubectl get ns #也是查看名称空间,只不过这里是简写形式而已
NAME STATUS AGE
default Active 9h
kube-node-lease Active 9h
kube-public Active 9h
kube-system Active 9h
[[email protected]~]#
[[email protected]~]# kubectl create namespace operation #创建一个叫做"operation"的名称空间
namespace/operation created
[[email protected]~]#
[[email protected]~]# kubectl create ns development
namespace/development created
[[email protected]~]#
[[email protected]~]# kubectl create ns testing
namespace/testing created
[[email protected]~]#
[[email protected]~]# kubectl get ns
NAME STATUS AGE
default Active 9h
development Active 38s
kube-node-lease Active 9h
kube-public Active 9h
kube-system Active 9h
operation Active 65s
testing Active 3s
[[email protected]~]#
[[email protected]~]#
2>.陈述式对象配置创建名称空间案例(重复创建时会报错,生产环境不推荐使用)
[[email protected] ~]# mkdir -pv /yinzhengjie/data/k8s/manifests/basic
mkdir: created directory ‘/yinzhengjie/data’
mkdir: created directory ‘/yinzhengjie/data/k8s’
mkdir: created directory ‘/yinzhengjie/data/k8s/manifests’
mkdir: created directory ‘/yinzhengjie/data/k8s/manifests/basic’
[[email protected]~]#
[[email protected]~]# cd /yinzhengjie/data/k8s/manifests/basic/
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# vim develop-ns.yaml
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# cat develop-ns.yaml
apiVersion: v1
kind: Namespace
metadata:
name: develop
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# kubectl get ns
NAME STATUS AGE
default Active 17h
kube-node-lease Active 17h
kube-public Active 17h
kube-system Active 17h
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# ll
total 4
-rw-r--r-- 1 root root 59 Feb 512:53 develop-ns.yaml
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# kubectl create -f develop-ns.yaml #使用陈述式对象配置创建名称空间
namespace/develop created
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# ll
total 4
-rw-r--r-- 1 root root 59 Feb 512:53 develop-ns.yaml
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# kubectl get ns
NAME STATUS AGE
default Active 17h
develop Active 8s
kube-node-lease Active 17h
kube-public Active 17h
kube-system Active 17h
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# kubectl create -f develop-ns.yaml #由于咱们定义的"develop"名称空间已经存在,因此给咱们抛出异常
Error from server (AlreadyExists): error when creating "develop-ns.yaml": namespaces "develop" already exists
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
3>.声明式对象配置创建名称空间案例(重复创建时并不会报错)
[[email protected] /yinzhengjie/data/k8s/manifests/basic]# cp develop-ns.yaml production-ns.yaml
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# vim production-ns.yaml
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# cat production-ns.yaml
apiVersion: v1
kind: Namespace
metadata:
name: production
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# ll
total 8
-rw-r--r-- 1 root root 59 Feb 512:53 develop-ns.yaml
-rw-r--r-- 1 root root 62 Feb 512:55 production-ns.yaml
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# kubectl get ns
NAME STATUS AGE
default Active 17h
develop Active 2m26s
kube-node-lease Active 17h
kube-public Active 17h
kube-system Active 17h
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# kubectl get namespace
NAME STATUS AGE
default Active 17h
develop Active 2m35s
kube-node-lease Active 17h
kube-public Active 17h
kube-system Active 17h
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# kubectl apply -f production-ns.yaml #使用声明式对象配置创建名称空间
namespace/production created
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# kubectl get namespace
NAME STATUS AGE
default Active 17h
develop Active 2m57s
kube-node-lease Active 17h
kube-public Active 17h
kube-system Active 17h
production Active 2s
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected]/yinzhengjie/data/k8s/manifests/basic]# kubectl apply -f production-ns.yaml #重复创建同一个名称空间时并不会报错,而是友好的提示咱们没有发生任何改变。
namespace/production unchanged
[[email protected]/yinzhengjie/data/k8s/manifests/basic]#
[[email protected] ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
mynginx-677d85dbd5-gkdb6 1/1 Running 0 5h12m
mynginx-677d85dbd5-vk5p5 1/1 Running 0 5h39m
[[email protected]~]#
[[email protected]~]# kubectl get pods mynginx-677d85dbd5-gkdb6 -o yaml --export > /yinzhengjie/data/k8s/manifests/basic/pod-demo.yaml
Flag --export has been deprecated, This flag is deprecated and will be removed in future.
[[email protected]~]#
[[email protected]~]#
[[email protected] ~]# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
mynginx-677d85dbd5-gkdb6 1/1 Running 0 5h23m 10.244.1.3 node201.yinzhengjie.org.cn
mynginx-677d85dbd5-vk5p5 1/1 Running 0 5h51m 10.244.2.2 node202.yinzhengjie.org.cn
[[email protected]~]#
[[email protected]~]# kubectl apply -f /yinzhengjie/data/k8s/manifests/basic/pod-demo.yaml #使用声明式对象配置创建pod
pod/pod-demo created
[[email protected]~]#
[[email protected]~]# kubectl apply -f /yinzhengjie/data/k8s/manifests/basic/pod01-demo.yaml #同上
pod/pod01-demo configured
[[email protected]~]#
[[email protected]~]# kubectl get pods -o wide #注意,此处我没有指定名称空间,因此我们查看的默认就是"default"这个名称空间哟~
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
mynginx-677d85dbd5-gkdb6 1/1 Running 0 5h34m 10.244.1.3 node201.yinzhengjie.org.cn
mynginx-677d85dbd5-vk5p5 1/1 Running 0 6h2m 10.244.2.2 node202.yinzhengjie.org.cn
[[email protected]~]#
[[email protected]~]# kubectl get pods -n develop -o wide #综上所述,如果我们想要查看创建的pod,应该去相应的名称空间去查看,很显然,我们在"develop"这个名称空间查看到了。
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod-demo 1/1 Running 0 13m 10.244.3.4 node203.yinzhengjie.org.cn
pod01-demo 1/1 Running 0 5m56s 10.244.3.5 node203.yinzhengjie.org.cn
[[email protected]~]#
三.使用声明式对象配置创建pod(在一个pod中创建2个容器)
1>.通过命令行查看pod这个资源如何定义的帮助文档
[[email protected] ~]# kubectl explain pods
KIND: Pod
VERSION: v1
DESCRIPTION:
Pod is a collection of containers that can run on a host. This resource is
created by clients and scheduled onto hosts.
FIELDS:
apiVersion <string>
APIVersion defines the versioned schema of this representation of an
object. Servers should convert recognized schemas to the latest internal
value, and may reject unrecognized values. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
kind <string>
Kind is a string value representing the REST resource this object
represents. Servers may infer this from the endpoint the client submits
requests to. Cannot be updated. In CamelCase. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
metadata
[[email protected] ~]# kubectl explain pods.apiVersion
KIND: Pod
VERSION: v1
FIELD: apiVersion <string>
DESCRIPTION:
APIVersion defines the versioned schema of this representation of an
object. Servers should convert recognized schemas to the latest internal
value, and may reject unrecognized values. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
[[email protected] ~]#
[[email protected] ~]# kubectl explain pods.kind
KIND: Pod
VERSION: v1
FIELD: kind <string>
DESCRIPTION:
Kind is a string value representing the REST resource this object
represents. Servers may infer this from the endpoint the client submits
requests to. Cannot be updated. In CamelCase. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
[[email protected] ~]#
[[email protected] ~]# kubectl explain pods.metadata
KIND: Pod
VERSION: v1
RESOURCE: metadata
DESCRIPTION:
Standard object's metadata. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
ObjectMeta is metadata that all persisted resources must have, which
includes all objects users must create.
FIELDS:
annotations
[[email protected] ~]# kubectl explain pods.spec
KIND: Pod
VERSION: v1
RESOURCE: spec
DESCRIPTION:
Specification of the desired behavior of the pod. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
PodSpec is a description of a pod.
FIELDS:
activeDeadlineSeconds
Optional duration in seconds the pod may be active on the node relative to
StartTime before the system will actively try to mark it failed and kill
associated containers. Value must be a positive integer.
affinity
If specified, the pod's scheduling constraints
automountServiceAccountToken
AutomountServiceAccountToken indicates whether a service account token
should be automatically mounted.
containers <[]Object> -required-
List of containers belonging to the pod. Containers cannot currently be
added or removed. There must be at least one container in a Pod. Cannot be
updated.
dnsConfig
Specifies the DNS parameters of a pod. Parameters specified here will be
merged to the generated DNS configuration based on DNSPolicy.
dnsPolicy <string>
Set DNS policy for the pod. Defaults to "ClusterFirst". Valid values are
'ClusterFirstWithHostNet', 'ClusterFirst', 'Default' or 'None'. DNS
parameters given in DNSConfig will be merged with the policy selected with
DNSPolicy. To have DNS options set along with hostNetwork, you have to
specify DNS policy explicitly to 'ClusterFirstWithHostNet'.
enableServiceLinks
EnableServiceLinks indicates whether information about services should be
injected into pod's environment variables, matching the syntax of Docker
links. Optional: Defaults to true.
ephemeralContainers <[]Object>
List of ephemeral containers run in this pod. Ephemeral containers may be
run in an existing pod to perform user-initiated actions such as debugging.
This list cannot be specified when creating a pod, and it cannot be
modified by updating the pod spec. In order to add an ephemeral container
to an existing pod, use the pod's ephemeralcontainers subresource. This
field is alpha-level and is only honored by servers that enable the
EphemeralContainers feature.
hostAliases <[]Object>
HostAliases is an optional list of hosts and IPs that will be injected into
the pod's hosts file if specified. This is only valid for non-hostNetwork pods.
hostIPC
Use the host's ipc namespace. Optional: Default to false.
hostNetwork
Host networking requested for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified.
Default to false.
hostPID
Use the host's pid namespace. Optional: Default to false.hostname <string>
Specifies the hostname of the Pod If not specified, the pod's hostname will
be set to a system-defined value.
imagePullSecrets <[]Object>
ImagePullSecrets is an optional list of references to secrets in the same
namespace to use for pulling any of the images used by this PodSpec. If
specified, these secrets will be passed to individual puller
implementations for them to use. For example, in the case of docker, only
DockerConfig type secrets are honored. More info:
https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod
initContainers <[]Object>
List of initialization containers belonging to the pod. Init containers are
executed in order prior to containers being started. If any init container
fails, the pod is considered to have failed and is handled according to its
restartPolicy. The name for an init container or normal container must be
unique among all containers. Init containers may not have Lifecycle
actions, Readiness probes, Liveness probes, or Startup probes. The
resourceRequirements of an init container are taken into account during
scheduling by finding the highest request/limit for each resource type, and
then using the max of of that value or the sum of the normal containers.
Limits are applied to init containers in a similar fashion. Init containers
cannot currently be added or removed. Cannot be updated. More info:
https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
nodeName <string>
NodeName is a request to schedule this pod onto a specific node. If it is
non-empty, the scheduler simply schedules this pod onto that node, assuming
that it fits resource requirements.
nodeSelector string]string>
NodeSelector is a selector which must be truefor the pod to fit on a node.
Selector which must match a node's labels for the pod to be scheduled on
that node. More info:
https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
overhead string]string>
Overhead represents the resource overhead associated with running a pod for
a given RuntimeClass. This field will be autopopulated at admission time by
the RuntimeClass admission controller. If the RuntimeClass admission
controller is enabled, overhead must not be set in Pod create requests. The
RuntimeClass admission controller will reject Pod create requests which
have the overhead already set. If RuntimeClass is configured and selected
in the PodSpec, Overhead will be set to the value defined in the
corresponding RuntimeClass, otherwise it will remain unset and treated as
zero. More info:
https://git.k8s.io/enhancements/keps/sig-node/20190226-pod-overhead.md This
field is alpha-level as of Kubernetes v1.16, and is only honored by servers
that enable the PodOverhead feature.
preemptionPolicy <string>
PreemptionPolicy is the Policy for preempting pods with lower priority. One
of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset.
This field is alpha-level and is only honored by servers that enable the
NonPreemptingPriority feature.
priority
The priority value. Various system components use this field to find the
priority of the pod. When Priority Admission Controller is enabled, it
prevents users from setting this field. The admission controller populates
this field from PriorityClassName. The higher the value, the higher the
priority.
priorityClassName <string>
If specified, indicates the pod's priority. "system-node-critical" and"system-cluster-critical" are two special keywords which indicate the
highest priorities with the former being the highest priority. Any other
name must be defined by creating a PriorityClass object with that name. If
not specified, the pod priority will be default or zero if there is no
default.
readinessGates <[]Object>
If specified, all readiness gates will be evaluated for pod readiness. A
pod is ready when all its containers are ready AND all conditions specified
in the readiness gates have status equal to "True" More info:
https://git.k8s.io/enhancements/keps/sig-network/0007-pod-ready%2B%2B.md
restartPolicy <string>
Restart policy for all containers within the pod. One of Always, OnFailure,
Never. Default to Always. More info:
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy
runtimeClassName <string>
RuntimeClassName refers to a RuntimeClass objectin the node.k8s.io group,
which should be used to run this pod. If no RuntimeClass resource matches
the named class, the pod will not be run. If unset or empty, the "legacy"
RuntimeClass will be used, which is an implicit class with an empty
definition that uses the default runtime handler. More info:
https://git.k8s.io/enhancements/keps/sig-node/runtime-class.md This is a
beta feature as of Kubernetes v1.14.
schedulerName <string>
If specified, the pod will be dispatched by specified scheduler. If not
specified, the pod will be dispatched by default scheduler.
securityContext
SecurityContext holds pod-level security attributes and common container
settings. Optional: Defaults to empty. See type description for default
values of each field.
serviceAccount <string>
DeprecatedServiceAccount is a depreciated alias for ServiceAccountName.
Deprecated: Use serviceAccountName instead.
serviceAccountName <string>
ServiceAccountName is the name of the ServiceAccount to use to run this
pod. More info:
https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
shareProcessNamespace
Share a single process namespace between all of the containers in a pod.
When this is set containers will be able to view and signal processes from
other containers in the same pod, and the first process in each container
will not be assigned PID 1. HostPID and ShareProcessNamespace cannot both
be set. Optional: Default to false.
subdomain <string>
If specified, the fully qualified Pod hostname will be
"...svc.". If not
specified, the pod will not have a domainname at all.
terminationGracePeriodSeconds
Optional duration in seconds the pod needs to terminate gracefully. May be
decreased in delete request. Value must be non-negative integer. The value
zero indicates delete immediately. If this value is nil, the default grace
period will be used instead. The grace period is the duration in seconds
after the processes running in the pod are sent a termination signal and
the time when the processes are forcibly halted with a kill signal. Set
this value longer than the expected cleanup timefor your process. Defaults
to 30 seconds.
tolerations <[]Object>
If specified, the pod's tolerations.
topologySpreadConstraints <[]Object>
TopologySpreadConstraints describes how a group of pods ought to spread
across topology domains. Scheduler will schedule pods in a way which abides
by the constraints. This field is alpha-level and is only honored by
clusters that enables the EvenPodsSpread feature. All
topologySpreadConstraints are ANDed.
volumes <[]Object>
List of volumes that can be mounted by containers belonging to the pod.
More info: https://kubernetes.io/docs/concepts/storage/volumes
[[email protected]~]#
[[email protected] ~]# kubectl explain pods.status
KIND: Pod
VERSION: v1
RESOURCE: status
DESCRIPTION:
Most recently observed status of the pod. This data may not be up to date.
Populated by the system. Read-only. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
PodStatus represents information about the status of a pod. Status may
trail the actual state of a system, especially if the node that hosts the
pod cannot contact the control plane.
FIELDS:
conditions <[]Object>
Current service state of pod. More info:
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions
containerStatuses <[]Object>
The list has one entry per container in the manifest. Each entry is
currently the output of `docker inspect`. More info:
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status
ephemeralContainerStatuses <[]Object>
Status for any ephemeral containers that have run in this pod. This field
is alpha-level and is only populated by servers that enable the
EphemeralContainers feature.
hostIP <string>
IP address of the host to which the pod is assigned. Empty if not yet
scheduled.
initContainerStatuses <[]Object>
The list has one entry per init container in the manifest. The most recent
successful init container will have ready = true, the most recently started
container will have startTime set. More info:
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status
message <string>
A human readable message indicating details about why the pod is in this
condition.
nominatedNodeName <string>
nominatedNodeName is set only when this pod preempts other pods on the
node, but it cannot be scheduled right away as preemption victims receive
their graceful termination periods. This field does not guarantee that the
pod will be scheduled on this node. Scheduler may decide to place the pod
elsewhere if other nodes become available sooner. Scheduler may also decide
to give the resources on this node to a higher priority pod that is created
after preemption. As a result, this field may be different than
PodSpec.nodeName when the pod is scheduled.
phase <string>
The phase of a Pod is a simple, high-level summary of where the Pod is in
its lifecycle. The conditions array, the reason and message fields, and the
individual container status arrays contain more detail about the pod's status. There are five possible phase values: Pending: The pod has been
accepted by the Kubernetes system, but one or more of the container images
has not been created. This includes time before being scheduled as well as
time spent downloading images over the network, which could take a while.
Running: The pod has been bound to a node, and all of the containers have
been created. At least one container is still running, or is in the process
of starting or restarting. Succeeded: All containers in the pod have
terminated in success, and will not be restarted. Failed: All containers in
the pod have terminated, and at least one container has terminated in
failure. The container either exited with non-zero status or was terminated
by the system. Unknown: For some reason the state of the pod could not be
obtained, typically due to an error in communicating with the host of the
pod. More info:
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-phase
podIP <string>
IP address allocated to the pod. Routable at least within the cluster.
Empty if not yet allocated.
podIPs <[]Object>
podIPs holds the IP addresses allocated to the pod. If this field is
specified, the 0th entry must match the podIP field. Pods may be allocated
at most 1 value for each of IPv4 and IPv6. This list is empty if no IPs
have been allocated yet.
qosClass <string>
The Quality of Service (QOS) classification assigned to the pod based on
resource requirements See PodQOSClass type for available QOS classes More
info:
https://git.k8s.io/community/contributors/design-proposals/node/resource-qos.md
reason <string>
A brief CamelCase message indicating details about why the pod is in this
state. e.g. 'Evicted'
startTime <string>
RFC 3339date and time at which the object was acknowledged by the Kubelet.
This is before the Kubelet pulled the container image(s) for the pod.
[[email protected]~]#
[[email protected] ~]# kubectl explain pods.spec.containers
KIND: Pod
VERSION: v1
RESOURCE: containers <[]Object>
DESCRIPTION:
List of containers belonging to the pod. Containers cannot currently be
added or removed. There must be at least one container in a Pod. Cannot be
updated.
A single application container that you want to run within a pod.
FIELDS:
args <[]string>
Arguments to the entrypoint. The docker image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the
container's environment. If a variable cannot be resolved, the reference in
the input string will be unchanged. The $(VAR_NAME) syntax can be escaped
with a double $$, ie: $$(VAR_NAME). Escaped references will never be
expanded, regardless of whether the variable exists or not. Cannot be
updated. More info:
https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
command <[]string>
Entrypoint array. Not executed within a shell. The docker image's
ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME)
are expanded using the container's environment. If a variable cannot be
resolved, the reference in the input string will be unchanged. The
$(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME).
Escaped references will never be expanded, regardless of whether the
variable exists or not. Cannot be updated. More info:
https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shellenv <[]Object>
List of environment variables to set in the container. Cannot be updated.
envFrom <[]Object>
List of sources to populate environment variables in the container. The
keys defined within a source must be a C_IDENTIFIER. All invalid keys will
be reported as an event when the container is starting. When a key exists
in multiple sources, the value associated with the last source will take
precedence. Values defined by an Env with a duplicate key will take
precedence. Cannot be updated.
image <string>
Docker image name. More info:
https://kubernetes.io/docs/concepts/containers/images This field is optional to allow higher level config management to default or override
container images in workload controllers like Deployments and StatefulSets.
imagePullPolicy <string>
Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always
if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated.
More info:
https://kubernetes.io/docs/concepts/containers/images#updating-images
lifecycle
Actions that the management system should take in response to container
lifecycle events. Cannot be updated.
livenessProbe
Periodic probe of container liveness. Container will be restarted if the
probe fails. Cannot be updated. More info:
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
name <string> -required-
Name of the container specified as a DNS_LABEL. Each container in a pod
must have a unique name (DNS_LABEL). Cannot be updated.
ports <[]Object>
List of ports to expose from the container. Exposing a port here gives the
system additional information about the network connections a container
uses, but is primarily informational. Not specifying a port here DOES NOT
prevent that port from being exposed. Any port which is listening on the
default "0.0.0.0" address inside a container will be accessible from the
network. Cannot be updated.
readinessProbe
Periodic probe of container service readiness. Container will be removed
from service endpoints if the probe fails. Cannot be updated. More info:
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
resources
Compute Resources required by this container. Cannot be updated. More info:
https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
securityContext
Security options the pod should run with. More info:
https://kubernetes.io/docs/concepts/policy/security-context/ More info:
https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
startupProbe
StartupProbe indicates that the Pod has successfully initialized. If
specified, no other probes are executed until this completes successfully.
If this probe fails, the Pod will be restarted, just as if the
livenessProbe failed. This can be used to provide different probe
parameters at the beginning of a Pod's lifecycle, when it might take a longtime to load data or warm a cache, than during steady-state operation. This
cannot be updated. This is an alpha feature enabled by the StartupProbe
feature flag. More info:
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
stdin
Whether this container should allocate a buffer for stdin in the container
runtime. If this is not set, reads from stdin in the container will always
result in EOF. Default is false.
stdinOnce
Whether the container runtime should close the stdin channel after it has
been opened by a single attach. When stdin is true the stdin stream will
remain open across multiple attach sessions. If stdinOnce is set to true,
stdin is opened on container start, is empty until the first client
attaches to stdin, and then remains open and accepts data until the client
disconnects, at whichtime stdin is closed and remains closed until the
container is restarted. If this flag is false, a container processes that
reads from stdin will never receive an EOF. Default is false
terminationMessagePath <string>
Optional: Path at which the file to which the container's termination
message will be written is mounted into the container's filesystem. Message written is intended to be brief final status, such as an assertion failure
message. Will be truncated by the node if greater than 4096 bytes. The
total message length across all containers will be limited to 12kb.
Defaults to /dev/termination-log. Cannot be updated.
terminationMessagePolicy <string>
Indicate how the termination message should be populated. File will use the
contents of terminationMessagePath to populate the container status message
on both success and failure. FallbackToLogsOnError will use the last chunk
of container log output if the termination message file is empty and the
container exited with an error. The log output is limited to 2048 bytes or
80 lines, whichever is smaller. Defaults to File. Cannot be updated.
tty
Whether this container should allocate a TTY for itself, also requires
'stdin' to be true. Default is false.
volumeDevices <[]Object>
volumeDevices is the list of block devices to be used by the container.
This is a beta feature.
volumeMounts <[]Object>
Pod volumes to mount into the container's filesystem. Cannot be updated.
workingDir <string>
Container's working directory. If not specified, the container runtime's
default will be used, which might be configured in the container image.
Cannot be updated.
[[email protected]~]#
[[email protected]~]#
[[email protected] ~]# kubectl explain pods.spec.containers.env
KIND: Pod
VERSION: v1
RESOURCE: env <[]Object>
DESCRIPTION:
List of environment variables to set in the container. Cannot be updated.
EnvVar represents an environment variable present in a Container.
FIELDS:
name <string> -required-
Name of the environment variable. Must be a C_IDENTIFIER.
value <string>
Variable references $(VAR_NAME) are expanded using the previous defined
environment variables in the container and any service environment
variables. If a variable cannot be resolved, the reference in the input
string will be unchanged. The $(VAR_NAME) syntax can be escaped with a
double $$, ie: $$(VAR_NAME). Escaped references will never be expanded,
regardless of whether the variable exists or not. Defaults to "".
valueFrom
Source for the environment variable's value. Cannot be used if value is not empty.
[[email protected]~]#
[[email protected]~]#
[[email protected] ~]# kubectl explain pods.spec.containers.env.name
KIND: Pod
VERSION: v1
FIELD: name <string>
DESCRIPTION:
Name of the environment variable. Must be a C_IDENTIFIER.
[[email protected]~]#
[[email protected] ~]# kubectl explain pods.spec.containers.env.valueFrom
KIND: Pod
VERSION: v1
RESOURCE: valueFrom
DESCRIPTION:
Source for the environment variable's value. Cannot be used if value is not empty.
EnvVarSource represents a source for the value of an EnvVar.
FIELDS:
configMapKeyRef
Selects a key of a ConfigMap.
fieldRef
Selects a field of the pod: supports metadata.name, metadata.namespace,
metadata.labels, metadata.annotations, spec.nodeName,
spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.
resourceFieldRef
Selects a resource of the container: only resources limits and requests
(limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu,
requests.memory and requests.ephemeral-storage) are currently supported.
secretKeyRef
Selects a key of a secret in the pod's namespace
[[email protected]~]#
[[email protected] ~]# kubectl get pods -n production
No resources found in production namespace.
[[email protected]~]#
[[email protected]~]# kubectl apply -f /yinzhengjie/data/k8s/manifests/basic/pod02-demo.yaml
pod/pod02-demo created
[[email protected]~]#
[[email protected]~]# kubectl get pods -n production #很明显,任务被调度到一台服务器后,需要一个创建过程(要先下载镜像文件),此时状态为"ContainerCreating"
NAME READY STATUS RESTARTS AGE
pod02-demo 0/2 ContainerCreating 0 3s
[[email protected]~]#
[[email protected]~]#
[[email protected]~]# kubectl get pods -n production
NAME READY STATUS RESTARTS AGE
pod02-demo 2/2 Running 0 19s
[[email protected]~]#
[[email protected]~]# kubectl get pods -n production -o wide #POD创建成功后状态为"Running",注意"READY"那一列是2个容器哟,我们上面定义了一个mynginx,另一个叫mybox
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod02-demo 2/2 Running 0 4m32s 10.244.1.4 node201.yinzhengjie.org.cn
[[email protected]~]#
[[email protected]~]#
GetUrlParam:function GetUrlParam(param){
var reg = new RegExp("(^|&)"+ param +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null
==================================================
1、打开PowerDesigner12,在菜单中按照如下方式进行操作
file->Reverse Engineer->DataBase
点击后,弹出 New Physical Data Model 的对话框
2、在General选项卡中
Model name:模板名字,自
网站配置是apache+tomcat,tomcat没有报错,apache报错是:
The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /. Reason: Error reading fr
Free variable A free variable of an expression is a variable that’s used inside the expression but not defined inside the expression. For instance, in the function literal expression (x: Int) => (x
Part Ⅰ:
《阿甘正传》Forrest Gump经典中英文对白
Forrest: Hello! My names Forrest. Forrest Gump. You wanna Chocolate? I could eat about a million and a half othese. My momma always said life was like a box ochocol
Json在数据传输中很好用,原因是JSON 比 XML 更小、更快,更易解析。
在Java程序中,如何使用处理JSON,现在有很多工具可以处理,比较流行常用的是google的gson和alibaba的fastjson,具体使用如下:
1、读取json然后处理
class ReadJSON
{
public static void main(String[] args)