Monday, 15 February 2021

Kubernetes Step by steps 0


To fun in Ubuntu 

  1  java -version

    2  sudo snap install intellij-idea-ultimate --classic

   10  ls

   13  sudo apt-get remove docker docker-engine docker.io containerd runc

   14  sudo apt-get update

   15  sudo apt-get install     apt-transport-https     ca-certificates     curl     gnupg-agent     software-properties-common

   16  sudo apt-get update

   17  sudo apt-get install docker-ce docker-ce-cli containerd.io

   18  sudo apt-get update

   19  sudo apt-get install     apt-transport-https     ca-certificates     curl     gnupg-agent     software-properties-common

   20  sudo apt-key fingerprint 0EBFCD88

   21  sudo add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \

   22     $(lsb_release -cs) \

   23     stable"

   24  docker -version

   25  sudo apt-get update

   26  sudo apt-get install docker-ce docker-ce-cli containerd.io

   27  docker -version

   28  docker --version

   29  clean

   30  clear

   31  cd Downloads

   32  sudo tar xf ideaIU-2020.3.2.tar.gz -C /opt/

   33  cd /opt/idea-IU-203.7148.57/bin/

   34  ./idea.sh

   35  curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

   36  curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"

   37  echo "$(<kubectl.sha256) kubectl" | sha256sum --check

   38  sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

   39  kubectl version --client

   40  sudo apt clean

   41  sudo apt update

   42  sudo rm /var/lib/apt/lists/lock

   43  sudo rm /var/cache/apt/archives/lock

   44  sudo rm /var/lib/dpkg/lock

   45  cd Downloads

   46  gdebi icaclient_21.1.0.14_amd64.deb 

   47  sudo apt install gdebi-core

   48  gdebi icaclient_21.1.0.14_amd64.deb 

   49  sudo apt install maven

   50  mvn -version

   51  java -version

   52  wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

   53  sudo apt install ./google-chrome-stable_current_amd64.deb

   54  sudo gdebi icaclient_21.1.0.14_amd64.deb

   55  sudo apt install gdebi-core

   56  sudo gdebi icaclient_21.1.0.14_amd64.deb

   57  cd Downloads/

   58  sudo gdebi icaclient_21.1.0.14_amd64.deb

   59  docker run hello-world

   60  sudo docker run hello-world

   61  docker run hello-world

   62  sudo docker run hello-world

   63  docker images

   64  sudo docker images

   65  sudo docker run   --name=donateyourbooks   --rm   --network=knote   -p 8080:8080 donateyourbooks

   66  sudo docker run   --name=donateyourbooks   --rm  -p 8080:8080 donateyourbooks

   67  sudo docker ps

   68  curl http://localhost:8080/

   69  curl http://localhost:9090/

   70  sudo -su

   71  sudo -s

   72  docker ps

   73  sudo docker ps

   74  curl http://localhost:8080/api/books

   75  curl http://localhost:9090/api/books

   76  sudo docker run   --name=donateyourbooks   --rm   --network=knote   -p 9090:8080 donateyourbooks

   77  sudo docker run   --name=donateyourbooks   --rm=donateyourbooks   --network=knote   -p 9090:8080 donateyourbooks

   78  sudo docker rm donateyourbooks

   79  sudo docker stop  donateyourbooks

   80  sudo docker rm donateyourbooks

   81  curl http://localhost:9090/api/books

   82  sudo docker run   --name=donateyourbooks   --rm   -p 9090:8080   donateyourbooks

   83  sudo docker run   --name=donateyourbooks   --rm   -p 9090:9090   donateyourbooks

   84  kubectl cluster-info

   85  kubectl --version

   86  kubectl -version

   87  kubectl -v

   88  kubectl v

   89  version

   90  kubectl version

   91  minikube start

   92  minikube start --driver=none

   93  sudo minikube start --driver=none

   94  kubectl cluster-info

   95  kubectl get po -A

   96  minikube kubectl -- get po -A

   97  minikube dashboard

   98  kubectl cluster-info

   99  minikube start

  100  curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb

  101  sudo dpkg -i minikube_latest_amd64.deb

  102  minikube start

  103  kubectl get po -A

  104  kubectl cluster-info

  105  minikube dashboard

  106  sudo su

  107  cd ~

  108  tar xjf firefox-*.tar.bz2

  109  ls

  110  cd Downloads/

  111  ls

  112  tar xjf firefox-85.0.2.tar.bz2

  113  ~/firefox/firefox

  114  ls

  115  cd /firefox/firefox

  116  cd /firefox/

  117  cd firefox/

  118  firefox 

  119  rm ~/.local/share/keyrings/*

  120  sudo apt-get update  

  121  sudo apt-get install -y apt-transport-https

  122  sudo apt install docker.io

  123  sudo systemctl start docker

  124  sudo systemctl enable docker 

  125  Docker -version  

  126  docker -version  

  127  docker version

  128  sudo apt-get install curl 

  129  sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add

  130  sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"

  131  sudo apt-get update

  132  sudo apt-get install -y kubelet kubeadm kubectl kubernetes-cni

  133  sudo swapoff -a

  134  sudo kubeadm init

  135  mkdir -p $HOME/.kube

  136  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

  137  sudo chown $(id -u):$(id -g) $HOME/.kube/config

  138  sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml 

  139  sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

  140  sudo kubectl get pods --all-namespaces

  141  minikube

  142  minikube version

  143  $ minikube start

  144  minikube start

  145  minikube start --vm-driver=none

  146  sudo systemctl stop docker.socket

  147  docker version --format {{.Server.Version}}

  148  sudo docker version --format {{.Server.Version}}

  149  docker info --format {{.CgroupDriver}}

  150  minikube start --vm-driver=none

  151  sudo minikube start --vm-driver=none --extra-config=kubelet.cgroup-driver=systemd

  152  docker info -f {{.CgroupDriver}}

  153  cgroupfs

  154  $ minikube start

  155  minikube start

  156  sudo minikube start --vm-driver=none --extra-config=kubelet.cgroup-driver=systemd

  157  minikube start --vm-driver=none --extra-config=kubelet.cgroup-driver=systemd

  158  systemctl --no-pager status kubelet

  159  journalctl -xeu kubelet

  160  sudo minikube start --vm-driver=none --extra-config=kubelet.cgroup-driver=systemd

  161  sudo sysctl fs.protected_regular=0

  162  sudo minikube start --vm-driver=none --extra-config=kubelet.cgroup-driver=systemd

  163  kubectl config get-context

  164  kubectl  get-context

  165  kubectl config

  166  kubectl config get-contexts

  167  kubectl get po -A

  168  minikube start

  169  curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb

  170  clear

  171  curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_arm64.deb

  172  sudo dpkg -i minikube_latest_arm64.deb

  173  dpkg --print-architecture

  174  dpkg --add-architecture amd64

  175  sudo dpkg --add-architecture amd64

  176  dpkg --print-foreign-architectures

  177  dpkg --print-architecture

  178  sudo dpkg -i minikube_latest_arm64.deb

  179  curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-latest.x86_64.rpm

  180  sudo rpm -ivh minikube-latest.x86_64.rpm

  181  minikube dashboard

  182  clear

  183  sudo install minikube-linux-amd64 /usr/local/bin/minikube

  184  minikube start

  185  grep PRETTY /etc/os-release 

  186  docker info --format "{{.CgroupDriver}}"

  187  cgroupfs

  188  minikube logs

  189  docker version --format {{.Server.Version}}

  190  sudo docker version --format {{.Server.Version}}

  191  docker info --format {{.CgroupDriver}}

  192  docker info --format {{Server.CgroupDriver}}

  193  sudo docker info --format {{Server.CgroupDriver}}

  194  udo systemctl stop docker.socket

  195  sudo systemctl stop docker.socket

  196  docker version --format {{.Server.Version}}

  197  sudo docker version --format {{.Server.Version}}

  198  docker info --format {{.CgroupDriver}}

  199  sudo docker info --format {{.CgroupDriver}}

  200  minikube start

  201  sudo apt-get update -y

  202  sudo apt-get upgrade -y

  203  sudo apt-get install curl

  204  sudo apt-get install apt-transport-https

  205  sudo apt install virtualbox virtualbox-ext-pack

  206  wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

  207  sudo cp minikube-linux-amd64 /usr/local/bin/minikube

  208  sudo chmod 755 /usr/local/bin/minikube

  209  minikube version

  210  curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl

  211  chmod +x ./kubectl

  212  sudo mv ./kubectl /usr/local/bin/kubectl

  213  kubectl version -o json

  214  minikube start

  215  kubectl config view

  216  kubectl cluster-info

  217  kubeadm init --ignore-preflight-errors=cri

  218  sudo kubeadm init --ignore-preflight-errors=cri

  219  kubeadm reset

  220  sudo kubeadm reset

  221  sudo kubeadm reset -f

  222  minikube start

  223  sudo minikube start --vm-driver=none --extra-config=kubelet.cgroup-driver=systemdsystemctl --no-pager status kubelet

  224  systemctl --no-pager status kubelet

  225  etc/docker/daemon.json

  226  /etc/docker/daemon.json

  227  /etc/docker/

  228  ls /etc/docker/

  229  etc/docker/daemon.json

  230  sudo apt-get update && sudo apt-get install -y containerdsudo apt-get update && sudo apt-get install -y containerd

  231  sudo mkdir -p /etc/containerd

  232  containerd config default | sudo tee /etc/containerd/config.toml

  233  sudo systemctl restart containerd

  234  /var/lib/kubelet/config.yaml

  235  sudo /var/lib/kubelet/config.yaml

  236  sudo vi /var/lib/kubelet/config.yaml

  237  cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf

  238  br_netfilter

  239  EOF

  240  cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf

  241  net.bridge.bridge-nf-call-ip6tables = 1

  242  net.bridge.bridge-nf-call-iptables = 1

  243  EOF

  244  sudo sysctl --system

  245  echo "$(<kubectl.sha256) kubectl" | sha256sum --check

  246  sudo echo "$(<kubectl.sha256) kubectl" | sha256sum --check

  247  curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

  248  curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"

  249  echo "$(<kubectl.sha256) kubectl" | sha256sum --check

  250  sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

  251  kubectl version --client

  252  minikube start

  253  sudo dpkg -i minikube_latest_amd64.deb

  254  minikube start --driver=docker

  255  minikube delete

  256  minikube start --driver=docker

  257  minikube config set driver docker

  258  minikube start --driver=docker

  259  docker info --format '{{.OSType}}'

  260  minikube start --driver=docker

  261  sudo minikube start --driver=docker

  262  minikube delete

  263  sudo minikube delete

  264  sudo minikube start --driver=docker

  265  minikube start --driver=docker

  266  udo usermod -aG docker $USER && newgrp docker'

  267  kubectl config get-context

  268  docker start

  269  docker run

  270  docker hel

  271  docker --help

  272  sudo docker run hello-world

  273  docker info --format

  274  docker --help

  275  systemctl status kubelet

  276  sudo docker run hello-world

  277  sudo chown "$USER":"$USER" /home/"$USER"/.docker -R

  278  sudo docker run hello-world

  279  minikube start --driver=docker

  280  sudo groupadd docker

  281  sudo usermod -aG docker $USER

  282  newgrp docker 

  283  sudo usermod -aG docker $USER && newgrp docker'

  284  1

  285  minikube kubectl -- get pods

  286  minikube start --help

  287  minikube config view

  288  kubectl config get-context

  289  kubectl config get-contexts

  290* Kubectl config de

  291  Kubectl config delete-contexts kubernetes-admin@mk

  292  kubectl config delete-contexts kubernetes-admin@mk

  293  kubectl config delete-context kubernetes-admin@mk

  294  kubectl config get-contexts

  295  kubectl get deployments

  296  kubectl get pods

  297  kubectl expose deployment hello-minikube --

  298  kubectl expose deployment hello-minikube

  299  kubectl expose deployment hello-minikube --port=8080

  300* kubectl expose deployment hello-minikube --type=NodePort$ kubectl get services

  301  kubectl expose deployment hello-minikube type=NodePort

  302  kubectl get services

  303  minikube service hello-minikube -—url

  304  minikube service hello-minikube --url

  305  curl http://192.168.49.2:31689

  306  kubectl logs hello-minikube

  307  kubectl logs hello-minikube-6ddfcc9757-jlbfc

  308  historyHere's a backup of commands executed in this section!


Refer to these if you face any problem




You can bookmark this URL as 


https://github.com/in28minutes/spring-microservices-v2/tree/main/05.kubernetes#comman




docker run -p 8080:8080 in28min/hello-world-rest-api:0.0.1.REL


kubectl create deployment hello-world-rest-api --image=in28min/hello-world-rest-api:0.0.1.RELEA

kubectl expose deployment hello-world-rest-api --type=LoadBalancer --port=808

kubectl scale deployment hello-world-rest-api --replicas=

kubectl delete pod hello-world-rest-api-58ff5dd898-62l9

kubectl autoscale deployment hello-world-rest-api --max=10 --cpu-percent=7

kubectl edit deployment hello-world-rest-api #minReadySeconds: 1

kubectl set image deployment hello-world-rest-api hello-world-rest-api=in28min/hello-world-rest-api:0.0.2.RELEAS


gcloud container clusters get-credentials in28minutes-cluster --zone us-central1-a --project solid-course-2581

kubectl create deployment hello-world-rest-api --image=in28min/hello-world-rest-api:0.0.1.RELEAS

kubectl expose deployment hello-world-rest-api --type=LoadBalancer --port=808

kubectl set image deployment hello-world-rest-api hello-world-rest-api=DUMMY_IMAGE:TES

kubectl get events --sort-by=.metadata.creationTimestam

kubectl set image deployment hello-world-rest-api hello-world-rest-api=in28min/hello-world-rest-api:0.0.2.RELEAS

kubectl get events --sort-by=.metadata.creationTimestam

kubectl get componentstatuse

kubectl get pods --all-namespace


kubectl get even

kubectl get pod

kubectl get replicase

kubectl get deploymen

kubectl get servic


kubectl get pods -o wi


kubectl explain po

kubectl get pods -o wid


kubectl describe pod hello-world-rest-api-58ff5dd898-9tr


kubectl get replicase

kubectl get replicase


kubectl scale deployment hello-world-rest-api --replicas

kubectl get pod

kubectl get replicase

kubectl get event

kubectl get events --sort.by=.metadata.creationTimestam


kubectl get 

kubectl get rs -o wid

kubectl set image deployment hello-world-rest-api hello-world-rest-api=DUMMY_IMAGE:TES

kubectl get rs -o wid

kubectl get pod

kubectl describe pod hello-world-rest-api-85995ddd5c-msjs

kubectl get events --sort-by=.metadata.creationTimestam


kubectl set image deployment hello-world-rest-api hello-world-rest-api=in28min/hello-world-rest-api:0.0.2.RELEA

kubectl get events --sort-by=.metadata.creationTimestam

kubectl get pods -o wid

kubectl delete pod hello-world-rest-api-67c79fd44f-n6c7

kubectl get pods -o wid

kubectl delete pod hello-world-rest-api-67c79fd44f-8bhd


gcloud container clusters get-credentials in28minutes-cluster --zone us-central1-c --project solid-course-2581

docker logi

docker push in28min/mmv2-currency-exchange-service:0.0.11-SNAPSHO

docker push in28min/mmv2-currency-conversion-service:0.0.11-SNAPSHO


kubectl create deployment currency-exchange --image=in28min/mmv2-currency-exchange-service:0.0.11-SNAPSH

kubectl expose deployment currency-exchange --type=LoadBalancer --port=800

kubectl get sv

kubectl get service

kubectl get pod

kubectl get p

kubectl get replicase

kubectl get r

kubectl get al


kubectl create deployment currency-conversion --image=in28min/mmv2-currency-conversion-service:0.0.11-SNAPSH

kubectl expose deployment currency-conversion --type=LoadBalancer --port=810


kubectl get svc --wat


kubectl get deploymen


kubectl get deployment currency-exchange -o yaml >> deployment.yam

kubectl get service currency-exchange -o yaml >> service.yaml


kubectl diff -f deployment.ya

kubectl apply -f deployment.yam


kubectl delete all -l app=currency-exchan

kubectl delete all -l app=currency-conversio


kubectl rollout history deployment currency-conversi

kubectl rollout history deployment currency-exchang

kubectl rollout undo deployment currency-exchange --to-revision=


kubectl logs currency-exchange-9fc6f979b-2gm

kubectl logs -f currency-exchange-9fc6f979b-2gmn8


kubectl autoscale deployment currency-exchange --min=1 --max=3 --cpu-percent=

kubectl get hp


kubectl top p

kubectl top node

kubectl get hp

kubectl delete hpa currency-exchang


kubectl create configmap currency-conversion --from-literal=CURRENCY_EXCHANGE_URI=http://currency-exchan

kubectl get configma


kubectl get configmap currency-conversion -o yaml >> configmap.ya


watch -n 0.1 curl http://34.66.241.150:8100/currency-conversion-feign/from/USD/to/INR/quantity/


docker push in28min/mmv2-currency-conversion-service:0.0.12-SNAPSH

docker push in28min/mmv2-currency-exchange-service:0.0.12-SNAPSHOTOT10mlpgeeasoda5  n81eonngelml l tsch0OTlstossc0OTTTn05telepSEpmseTerspsts=3ttsh2edsdeettstssspEpT0E05E50d30SEEASEdswells!