33
loading...
This website collects cookies to deliver better user experience
default
. It is also possible to create new namespaces. If you have used docker swarm
before, you can think of a namespace as a stack
.apiVersion: v1
kind: Namespace
metadata:
name: development
labels:
name: development
template:
spec:
containers:
- name: hello
image: hello-world
restartPolicy: OnFailure
workload controller
. They are responsible for managing the life cycle of a workload such as a job
and deployment
. Below is a workload definition. The corresponding controller will make sure that the state of the system matches the definition.apiVersion: batch/v1
kind: Job
metadata:
name: hello-world
spec:
template:
spec:
containers:
- name: hello
image: hello-world
restartPolicy: OnFailure
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 9376
kube-proxy
and happens on layer 4.kube-proxy
determines the load balancing algorithm.pod-ip-address.my-namespace.pod.cluster-domain.example.
pod-ip-address.deployment-name.my-namespace.svc.cluster-domain.example
<service-name>.<namespace-name>.svc.cluster.local
<service-name>
it will resolve to the service bound to the same namespace as the pod making the DNS query./ect/resolve.conf
that has the following form.search <namespace>.svc.cluster.local svc.cluster.local cluster.local
FQDN
, from within a container, using dig, the +search
flag has to be used.dig +search <service-name>
alive
and ready
to accept requests. As long as all specified container has a corresponding process ID (PID), the pod is considered healthy.apiVersion: apps/v1
kind: Deployment
metadata:
name: healthcheck-me
spec:
template:
metadata:
labels:
app: healthcheck-me
spec:
containers:
- name: healthcheck-me
image: localhost/checkme
ivenessProbe:
httpGet:
path: /healthz
port: 80
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
When a pod ceases to exist, Kubernetes destroys ephemeral volumes; however, Kubernetes does not destroy persistent volumes. For any kind of volume in a given pod, data is preserved across container restarts.
apiVersion: v1
kind: Pod
metadata:
name: configmap-pod
spec:
containers:
- name: test
image: busybox
volumeMounts:
- name: config-vol
mountPath: /etc/config
volumes:
- name: config-vol
configMap:
name: log-config
items:
- key: log_level
path: log_level
AWS
, GCP
and Azure
have their own volume type which provisions storage in the respect cloud platform.Volume Type | Description |
---|---|
configMap (ephemeral) | A ConfigMap provides a way to inject configuration data into pods. |
emptyDir (ephemeral) | An emptyDir volume is first created when a Pod is assigned to a node, and exists as long as that Pod is running on that node. |
hostPath | A hostPath volume mounts a file or directory from the host node's filesystem into your Pod. |
local | A local volume represents a mounted local storage device such as a disk, partition or directory. |
nfs | An nfs volume allows an existing NFS (Network File System) share to be mounted into a Pod. |
persistentVolumeClaim | A persistentVolumeClaim volume is used to mount a PersistentVolume into a Pod. |
secret (epehemral) | A secret volume is used to pass sensitive information, such as passwords, to Pods. |