Kubernetes CKAD

 Configuration:

In Docker | In kubernetes yaml file

CMD - args

ENTRYPOINT - command

  • The command opton specified in yaml file will overide the entry point specified in docker file,same with the case of args

Config maps:


1.Create config map imperative way:


2.Declare in a separate yaml file in declarative way as shown below and use in pod definition file:


3. Use only single key property or use in volumes


Secrets:

It is not good practice to store sensitive information in configmap, so we use secrets sytanxes of both looks like almost same

1.Creating secrets using imperative way


2.Creating  secrets using declarative way


3.Use only single key property or use in volumes

4.we didn't store actual passwords,we use base64 encoding, see below


5.we can decode base64 encoded strings as below


6. viewing secret maps

Security context:

If we want to add specific capabilties to containers,we can add in pod-definition file as shown below


We can do the same in docker from docker run command, using --cap-add and  --cap-drop flags.The former is used to add capabilities and later is used to remove.

Service Accounts:


Resource Requirements:

  • By default each pod uses, 0.5 cpu and 256 Mb of memeory,we can edit them in pod definition file as shown below
  • In docker, a container can utilise as many resources as it can i.e available in host node, there is no specific limit, so it could impact performance of host node oor other containers
  • But we can limit these valaues in pod definition file or dployment file as shown below, by default the limit was 1 cpu and 512 MB




Readines and liveness probes:

click here

Volumes:

EmpthDir:
  • An emptyDir volume is a volume type that is first created when a Pod is assigned to a Node.
  •  Its lifespan is dependent on the lifecycle of the Pod on that Node but recreates when the containers crash or restart. 
  • If we kill the pod, then data will be lost
  • If we restart the container inside the pod, then data will be retained, its scope is inside of the pod
Host Volumes:
  • hostPath volume type is a durable volume type that mounts a directory from the host Node’s filesystem into a Pod. 
  • The file in the volume remains intact even if the Pod crashes, is terminated or is deleted.
  •  It is important that the directory and the Pod are created or scheduled on the same Node. 
  • If we want to retain data across different worker nodes in a cluster, then we need to use NFS(Network File system) or cloud storage
  • See the practical example of host volumes in below blog
Eg:Using AWS Elastic Block storage
apiVersion: v1
kind: Pod
metadata:
  name: test-ebs
spec:
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container
    volumeMounts:
    - mountPath: /test-ebs
      name: test-volume
  volumes:
  - name: test-volume
    # This AWS EBS volume must already exist.
    awsElasticBlockStore:
      volumeID: "<volume id>"
      fsType: ext4
Volumes which uses configmaps and secrets:
video
Eg: code

Persistant volumes,persistance volume claims and storage classes

here
blog

Stateful sets:


Comments

Popular posts from this blog

Docker Imp points

Docker volumes backup and restore & Docker networks