Posts

Showing posts from September, 2021

Kubernetes CKAD

Image
 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: blog 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: Blog 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 comm...

Kubernetes more ...

Image
Create an NGINX Pod kubectl run nginx --image=nginx Generate POD Manifest YAML file (-o yaml). Don't create it(--dry-run) kubectl run nginx --image=nginx --dry-run=client -o yaml Create a deployment kubectl create deployment --image=nginx nginx Generate Deployment YAML file (-o yaml). Don't create it(--dry-run) kubectl create deployment --image=nginx nginx --dry-run=client -o yaml Generate Deployment YAML file (-o yaml). Don't create it(--dry-run) with 4 Replicas (--replicas=4) kubectl create deployment --image=nginx nginx --dry-run=client -o yaml > nginx-deployment.yaml Save it to a file, make necessary changes to the file (for example, adding more replicas) and then create the deployment. kubectl create -f nginx-deployment.yaml OR In k8s version 1.19+, we can specify the --replicas option to create a deployment with 4 replicas. kubectl create deployment --image=nginx nginx --replicas=4 --dry-run=client -o yaml > nginx-deployment.yaml Note: if we don't want to c...

Kubernetes

Image
1. Basic commands: kubectl run nginx --image=nginx  - gets the nginx image from the docker repository and launches apod with name nginx in cluster. kubectl get nodes - to get list of nodes kubectl describe pod nginx - gets all the properties of pod with nane nginx,like container id,ip address of pod and ip address of node etc kubectl delete pods <pod name> - To delete pods kubectl delete replicasets <replicaset name> -  To delete replica sets kubectl delete deployments <deployment name> - To delete deployments -------------------------------  kubectl delete --all svc --namespace=default - To delete all services in a namespace at once,similary pods,replicasets and deployments replace svc with pods,rc and deploy respectively  2. Pods: Every thing about pods like creating pods using kubectl,using yaml file and remove those etc,nice blog here 3.Replica set: blog: here video: here we can edit replaceset yaml definition file using and use kubectl replace ...

Kubernetes installation

 In RHEL family distribution using minicube: here Install kubernetes using kubeadm in centos7 - here

Docker Swarm

Image
 Docker swarm: docker swarm init   - This will start swarm service and the host in which ypu executed this command will become leader   - It will give some result and we need to paste that code in worker nodes and we ned to enable 2377              port for communication  docker swarm leave - The node will come out of cluster Docker service commands: 1.docker service create -p 80:80 --replicas=3 --name=web --niginx If we don't specify any replicas by default 1 service will be created 2. docker service ls It will list services 3. docker service  ps web  List the tasks of one or more services, it will display information of service like on which workers how many instances are running and which is leader,reachable and worker etc, if we do docker inspect of taskID,we can see many more details 4. docker service scale web=3 we can scale or descale number of instances of service running by giving its number 5. docker service insp...

Docker volumes backup and restore & Docker networks

 Backup and restore docker volumes Official link Youtube Best aricle for volumes backup and restoration Docker neworks: Network drivers: Network driver summary : Bridge network Official link : The default network used by docker if we do not specify any option is bridge network We can create our own bridge network, Containers on the default bridge network can only access each other by IP addresses, unless you use the --link option , which is considered legacy. On a user-defined bridge network, containers can resolve each other by name or alias. We can create bridge network as shown below      $docker network create <network name>   If we don't specify any network driver then by default it is bridge and we can define subnet and default gateways by using different flagsf we can add container to user defined network 2 ways While creating docker container from image using --network or --net flag        $docker run --it --net=<network na...

Docker Imp points

  1. docker run -it <image> <any command like ls>  - It will start the container execute the command and stop the container.The status of the stopped container can be seen using docker ps -a 2. docker run -it --rm <image> <any command like ls> - It will do the same the same hing, but after stopping it will also kills the container 3. If we run an docker image without specifying -d(detached mode),then we will enter into container directly and if we exit the container will be stopped 4.If we run container in detached mode by specifying -d,as shown below image will run in background,we can connect to it using exec. Eg:$docker run -itd <image> 5. About user in docker file: - If we specify any user in dockerfile, all the commands will be executed by that user and in  the image that user is retained, i.e if you make a container out of it,we will get same user. - If we want to switch user,you can do so using another user instruction in docker file a...