Training Commands and steps # Training # AWS machine mumbai region launch instance (opt out old ) Amazon linux 2 AMI HVM kernal 5.10 SSD volume Free tier eligible 84 t2 medium 2,4 Just increase the size to 10 GB Volumen tyoe gp2 Can check the volume type pricing and add new volume security wizard 4 # Docker kubernetes and minikube installation [https://www.zekelabs.com/blog/how-to-install-kubernetes-cluster-on-aws-ec2-instances/](https://) ## Docker installation yum install docker -y systemctl enable docker && systemctl start docker systemctl status docker docker version docker images ## kubernetes installation ``` cat <<EOF > /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=1 repo_gpgcheck=0 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg exclude=kube* EOF ``` Exclude the `` above before execitung ``` cat <<EOF > /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 EOF sysctl --system setenforce 0 ``` yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes systemctl enable kubelet && systemctl start kubelet ## Minikube installation [https://minikube.sigs.k8s.io/docs/start/](https://) ``` curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 sudo install minikube-linux-amd64 /usr/local/bin/minikube ``` minikube start --driver=none kubectl get nodes # Docker commands https://www.tutorialspoint.com/docker/docker_file.htm docker container ls ##it wil show the kube containers .Kubecomponents (proxy ,scheduler etcd ,apiserver) docker run --name mynginx1 -p 80:80 -d nginx port forwarding to 80 ##this could be done by compose file . ##check on the aws public Ip on port 80 . unsecure http. ##lets get inside the docker container and change the index.html ##check the size of teh container docker exec -it <containerid > sh cd /usr/share/nginx/html ##as we need and editor as its very basic image without any software . apt-get update && apt-get install vim # Helm installation https://helm.sh/docs/intro/install/ From Script `curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3` `chmod 700 get_helm.sh` `./get_helm.sh` helm version helm list `helm repo add bitnami https://charts.bitnami.com/bitnami` helm repo list # ppt from fresco # Kubernetes commands kubectl run nginx --image=nginx kubectl run nginx --image=nginx --dry-run=client -o yaml >>nginxDeployment.yaml ## deployment kubectl create deployment --image=nginx nginxdeploy --dry-run=client kubectl scale deployment nginx --replicas=4 ## service kubectl expose pods redis --port=6397 --name redis-service --dry-run=client -o yaml >redisSvc kubectl create service clusterIP redis --tcp=6397:6397 kubectl expose pod nginx --type=NodePOrt --port=80 --name=nginxService kubectl expose deployment ngDeploy --type=NodePort --port 80 --name=nginxService kubectl explain pods --recursive |less # Helm commands and deployment helm search repo helm add bitnami http:// helm search repo |grep -i mysql helm install stable/mysql --genrate-name https://www.katacoda.com/mjboxboat/courses/kubernetes-fundamentals-2/04-helm ## Helm commands for revision and upgrade https://getbetterdevops.io/helm-quickstart-tutorial/ 310 helm create nginx 311 ls 312 ll 313 date 314 tree nginx 315 yum install tree 316 tree nginx 317 cd tree 318 cd nginx/ 319 ll 320 cat values.yaml 321 helm lint nginx ' 322 helm lint nginx 323 cd .. 324 helm lint nginx 325 helm install --debug --dry-run nginx nginx 326 helm install nginx nginx 327 kubectl get all 328 cd nginx/ 329 ll 330 vi values.yaml 331 helm upgrade nginx nginx --set image.tag=1.21.6 332 cd .. 333 helm upgrade nginx nginx --set image.tag=1.21.6 334 kubectl get pod -l app.kubernetes.io/name=nginx -o jsonpath='{.items[0].spec.containers[0].image}' 335 helm history nginx 336 cd nginx/ 337 ll 338 cat values.yaml |grep -i replica 339 helm upgrade nginx nginx --set replicaCount=2 340 cd .. 341 helm upgrade nginx nginx --set replicaCount=2 342 helm history nginx 343 kubectl get all 344 helm diff revision nginx 1 2 345 helm diff --help 346 helm --help 347 helm history nginx 348 helm diff nginx 1 2 349 helm rollback nginx 2 350 kubectl get all 351 helm history nginx 352 $ kubectl get pod -l app.kubernetes.io/name=nginx -o jsonpath='{.items[0].spec.containers[0].image}' 353 $ kubectl get pod -l app.kubernetes.io/name=nginx -o jsonpath='{.items[0].spec.containers[0].image} 354 $ kubectl get pod -l app.kubernetes.io/name=nginx -o jsonpath='{.items[0].spec.containers[0].image}' 355 kubectl get pod -l app.kubernetes.io/name=nginx -o jsonpath='{.items[0].spec.containers[0].image}' 356 helm uninstall nginx 357 ls Jenkin installation in AWS https://www.jenkins.io/doc/tutorials/tutorial-for-installing-jenkins-on-AWS/