Skip to content

Jaibw/docker-v1

Repository files navigation

# Docker installation 

wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/install-docker-ubuntu-20.04.sh 
sh install-docker-ubuntu-20.04.sh
# refresh your chrome 
docker --version 

docker run hello-world 
docker images

docker version
systemctl status docker    # press q to exit 
which docker               

docker images
docker pull nginx
docker images
docker pull redis
docker pull ubuntu
docker pull centos
docker images
docker pull nginx:1.9.5
docker images
# explore more images on hub.docker.com


mkdir ~/hello-python
cd ~/hello-python
wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/hello-python/Dockerfile
wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/hello-python/main.py
ls -l
docker build -t hello-python:v1 .
docker images 
docker run hello-python:v1 


# open second terminal using duplicate tab in chrome 
# 1st tab
docker run nginx 
# 2nd tab 
ps aux | grep nginx 
# 1st tab 
Ctrl + C to terminate your container 
# 2nd tab 
ps aux | grep nginx 


docker run ubuntu ls /
docker run ubuntu ps aux 
docker run ubuntu uname -a
docker run centos uname -a
docker run -it ubuntu /bin/bash
# vim --version 
# apt update 
# apt install vim -y 
# vim --version 
# exit 

sudo ls /var/lib/docker
sudo ls /var/lib/docker/image
sudo cat /var/lib/docker/image/overlay2/repositories.json
docker images
sudo ls /var/lib/docker/image/overlay2/layerdb/sha256


docker image inspect hello-python:v1
docker run jpetazzo/clock   # ctrl + c to exit 
docker run nginx            # ctrl + c to exit   
docker run -d jpetazzo/clock
docker run -d nginx 
docker ps 
docker logs <container-id>
docker ps 
docker ps -l 
docker ps -a
docker ps -q
docker ps -qa


docker run --name myapp -d nginx 
docker ps 
docker stop myapp 
docker ps -a
docker start myapp
docker ps 
docker kill myapp
docker ps -a
docker restart myapp
docker ps 
docker attach myapp    # ctrl + c to exit 
docker ps -a
docker start myapp 
docker ps 
docker logs myapp
docker exec myapp ls -l /proc
docker exec -it  myapp /bin/bash
# apt update && apt install vim -y 
# exit 
docker ps 
docker exec myapp vim --version


docker inspect myapp | less
docker inspect myapp | grep -i ipaddress
curl 172.#.#.#

docker ps
docker rm myapp
docker stop myapp
docker ps  -a
docker rm myapp
docker ps  -a | grep hello-world
docker rm <container-id> <container-id>
docker ps  -a | grep hello-world
docker system df
docker system info
docker system events    # ctrl + c to exit 
docker system prune
docker ps -a


docker run -it ubuntu /bin/bash
# hostname 
# exit 
docker run --hostname=front-end-app  -it ubuntu /bin/bash
# hostname 
# exit 
docker ps 
docker run --name=myapp -d nginx 
docker ps 
docker top myapp
docker stats
docker run -m 500M --memory-reservation 200M --name=myapp02 -d nginx 
docker run --cpus 0.02 --name=myapp03 -d nginx 
docker ps 
docker stats

docker volume 
docker volume create mysql-db
docker volume ls 
docker volume inspect mysql-db 
sudo ls /var/lib/docker/volumes/mysql-db/_data
docker run --name mysql -e MYSQL_ROOT_PASSWORD=password -v  mysql-db:/var/lib/mysql -d mysql 
sudo ls /var/lib/docker/volumes/mysql-db/_data
docker exec -it mysql /bin/bash
# mysql -u root -p
# Enter password: password
# mysql > create database demo;
# mysql > show databases;
# mysql > exit 
# exit 
docker stop mysql 
docker rm mysql 
sudo ls /var/lib/docker/volumes/mysql-db/_data
docker run --name mysql1 -e MYSQL_ROOT_PASSWORD=password -v  mysql-db:/var/lib/mysql -d mysql
docker exec -it mysql1 /bin/bash
# mysql -u root -p
# Enter password: password
# mysql > show databases;
# mysql > exit 
# exit 

cd ~
git clone https://github.com/Jaibw/FrozenYogurtShop.git
ls /home/ubuntu/FrozenYogurtShop
docker run --name website001 -v /home/ubuntu/FrozenYogurtShop:/usr/share/nginx/html -d nginx
docker ps 
docker inspect website001 | grep -i ipaddress
curl 172.#.#.#


docker run --name website001 -p 8081:80 -v /home/ubuntu/FrozenYogurtShop:/usr/share/nginx/html -d nginx
Open Chrome http://PublicIP:8081 


cd ~/hello-python
docker login 
docker build -t DOCKER-USERNAME/hello-python .     ## eg. docker build -t jaibw/hello-python .
docker push DOCKER-USERNAME/hello-python           ## eg. docker push jaibw/hello-python 
Open DockerHub and search for DOCKER-USERNAME/hello-python  

docker search DOCKER-USERNAME
docker search rabbitmq
docker rmi DOCKER-USERNAME/hello-python

docker ps
docker stop `docker ps -q`
docker ps 
docker ps -qa
docker rm `docker ps -qa`
docker ps -a
docker images 
docker rmi python
docker images
docker system prune --all
docker images 
docker volume ls
docker volume prune 

docker images 
docker pull nginx 
docker images
docker run --name web -d nginx 
docker ps 
docker exec -it web /bin/bash
# apt update 
# apt install vim nano default-jdk -y 
# exit
docker ps -a
docker images
docker commit web USERNAME/web-base:v1 
docker images


mkdir ~/custom-apache
cd ~/custom-apache/
wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/custom-apache/Dockerfile
cat Dockerfile 
docker build -t webserver:v1 .
docker images 
docker run -d --name demo01 webserver:v1 
docker inspect demo01 | grep -i ipaddress 
curl 172.#.#.#
docker stop demo01 

mkdir ~/hello-java
cd ~/hello-java
wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/hello-java/Dockerfile
wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/hello-java/Hello.java
cat Dockerfile 
cat Hello.java 
docker build -t hello-java:v1 .
docker images
docker run hello-java:v1
docker run -it hello-java:v1 /bin/bash
# ls 
# java Hello
# exit 
cat Dockerfile 

mkdir ~/corporate-image
cd ~/corporate-image
wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/corporate-image/Dockerfile
docker build -t base-ubuntu .
docker run -it base-ubuntu
# nano --version 
# cd /data
# echo 'demo' > file1.txt 
# exit 
docker volume ls 
docker history base-ubuntu

mkdir ~/mysql-db
cd ~/mysql-db
wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/mysql-db/Dockerfile
vim Dockerfile
docker build -t mysql-db .
docker images
docker run -d --name mysql mysql-db 
docker ps 
docker exec -it mysql /bin/bash
# mysql -u root -p 
# Password:  --- type password 
# mysql > exit 
# exit 


docker stop `docker ps -q`
docker rm `docker ps -qa`
mkdir ~/wordpress/db
mkdir -p ~/wordpress/db
mkdir -p ~/wordpress/app
cd ~/wordpress/db
wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/mysql-db/Dockerfile
docker build -t mysql-db .
docker run -d --name mysql mysql-db 
cd ~/wordpress/app
wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/wordpress/Dockerfile
cat Dockerfile 
docker inspect mysql | grep -i ipaddress
sed -i 's/DATABASEIP/172.#.#.#/g' Dockerfile 
cat Dockerfile
docker build -t wp-app .
docker run -d --name wordpress -p 8080:80 wp-app 
Open chrome http://PublicIP:8080/


docker login jaibw.jfrog.io
docker pull nginx 
docker tag nginx jaibw.jfrog.io/devops-docker/nginx:YOURNAME
docker push jaibw.jfrog.io/devops-docker/nginx:YOURNAME


cd ~
wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/docker-compose/wordpress.yaml
cat wordpress.yaml
docker-compose help 
docker-compose -f wordpress.yaml up 
Access http://PublicIP:8081/
Press Ctrl + c to exit from docker-compose up command 


docker stop `docker ps -q`
docker rm `docker ps -qa`
docker system prune --all 
docker volume prune 

wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/docker-compose/ovs.yaml
cat ovs.yaml
docker-compose -f ovs.yaml -p ovs up 


Access App
http://PublicIP:8082
http://PublicIP:8082/swagger-ui.html 

Acess DB Admin Utility: 
Find DB details - https://raw.githubusercontent.com/Jaibw/docker-v1/master/docker-compose/ovs.yaml 
http://PublicIP:8083

docker-compose -f ovs.yaml -p ovs start    ## start it as a service 
docker-compose -f ovs.yaml -p ovs stop     ## stop the service 



docker stop `docker ps -q`
docker rm `docker ps -qa`
docker system prune --all 
docker volume prune 

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
sudo dpkg -i minikube_latest_amd64.deb
minikube version
minikube start --driver=docker
minikube kubectl -- get pods -A
docker ps 
docker ps -a

minikube help
minikube status
minikube dashboard
minikube addons list
minikube addons enable metrics-server 
minikube addons list

## Kubernetes Production Grade Setup - Multi-node cluster 

master> sudo apt update
master> sudo apt -y upgrade
master> sudo systemctl reboot

worker01> sudo apt update
worker01> sudo apt -y upgrade
worker01> sudo systemctl reboot

master> sudo hostnamectl set-hostname master
master> REFRESH MY SESSION 

worker01> sudo hostnamectl set-hostname worker01
worker01> REFRESH MY SESSION


# Install kubelet, kubeadm and kubectl

master> sudo apt -y install curl apt-transport-https
master> curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
master> echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
master> sudo apt update
master> sudo apt -y install vim git curl wget kubelet=1.23.7-00 kubeadm=1.23.7-00 kubectl=1.23.7-00
master> sudo apt-mark hold kubelet kubeadm kubectl
master> kubectl version --client
master> kubeadm version

worker01> sudo apt -y install curl apt-transport-https
worker01> curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
worker01> echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
worker01> sudo apt update
worker01> sudo apt -y install vim git curl wget kubelet=1.23.7-00 kubeadm=1.23.7-00
worker01> sudo apt-mark hold kubelet kubeadm
worker01> kubeadm version

# Turn off swap 
master> sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
master> sudo swapoff -a

worker01> sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
worker01> sudo swapoff -a

# Enable kernel modules
master> sudo modprobe overlay
master> sudo modprobe br_netfilter

worker01> sudo modprobe overlay
worker01> sudo modprobe br_netfilter


# Add some settings to sysctl
master> sudo tee /etc/sysctl.d/kubernetes.conf<<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF

worker01> sudo tee /etc/sysctl.d/kubernetes.conf<<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF

# Reload sysctl
master> sudo sysctl --system

worker01> sudo sysctl --system


# Install and configure docker and other services 
master> sudo apt install -y gnupg2 software-properties-common apt-transport-https ca-certificates
master> curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
master> sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
master> sudo apt update
master> sudo apt install -y containerd.io docker-ce docker-ce-cli
master> sudo mkdir -p /etc/systemd/system/docker.service.d
master> sudo tee /etc/docker/daemon.json <<EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF

# Start and enable Services
master> sudo systemctl daemon-reload 
master> sudo systemctl restart docker
master> sudo systemctl enable docker
master> sudo systemctl enable kubelet


worker01> sudo apt install -y gnupg2 software-properties-common apt-transport-https ca-certificates
worker01> curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
worker01> sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
worker01> sudo apt update
worker01> sudo apt install -y containerd.io docker-ce docker-ce-cli
worker01> sudo mkdir -p /etc/systemd/system/docker.service.d
worker01> sudo tee /etc/docker/daemon.json <<EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF

# Start and enable Services
worker01> sudo systemctl daemon-reload 
worker01> sudo systemctl restart docker
worker01> sudo systemctl enable docker
worker01> sudo systemctl enable kubelet


# Initialize Kubernetes Cluster 
master> sudo docker images  
master> sudo kubeadm config images pull
master> sudo docker images
master> sudo kubeadm help init
master> sudo kubeadm init --pod-network-cidr=10.100.0.0/16 --service-cidr=10.150.0.0/16 --upload-certs

worker01> sudo kubeadm join 172.#.#.#:6443 --token ###### --discovery-token-ca-cert-hash sha256:#######


master> sudo cat /etc/kubernetes/admin.conf 
master> mkdir -p $HOME/.kube
master> kubectl cluster-info
master> sudo cp -f /etc/kubernetes/admin.conf $HOME/.kube/config
master> sudo chown $(id -u):$(id -g) $HOME/.kube/config
master> kubectl cluster-info
master> kubectl get nodes  
master> kubectl get nodes -o wide 
master> kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
master> watch kubectl get nodes
# Press Ctrl + c when your both nodes are in ready state 
master> kubectl get pods --all-namespaces

## PODS
master> kubectl get pods
master> kubectl get ns
master> kubectl run web --image=nginx
master> kubectl get pods
master> kubectl get pods -o wide 
master> kubectl describe  pods web
master> kubectl logs  web
master> kubectl get pods -o wide 
master> curl 10.#.#.#

worker01> sudo docker ps | grep web 
worker01> curl 10.#.#.#


master> wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/pod.yaml
master> cat pod.yaml
master> kubectl create -f pod.yaml 
master> kubectl get pods -o wide
master> curl 10.#.#.#
master> kubectl describe pods web01
master> kubectl logs web01
master> kubectl get pods
master> kubectl delete pod web
master> kubectl delete -f pod.yaml 
master> kubectl get pods

worker01> sudo docker ps | grep web01 


master> kubectl create -f https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/pod-multi.yaml 
master> kubectl get pods -o wide
master> curl 10.#.#.#
master> kubectl describe pods web02
master> kubectl logs web02 app
master> kubectl logs web02 db
worker01> sudo docker ps | grep web02 


master> wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/replication-controller.yaml
master> kubectl create -f replication-controller.yaml 
master> kubectl get replicationcontroller 
master> kubectl get rc
master> kubectl get pods
master> kubectl get pods -o wide 
master> kubectl delete pod myapp-web-#####
master> kubectl get pods -o wide 
master> cat replication-controller.yaml 
master> sed -i 's/replicas: 3/replicas: 6/g' replication-controller.yaml 
master> cat replication-controller.yaml 
master> kubectl replace -f replication-controller.yaml 
master> kubectl get rc
master> kubectl get pods -o wide 
master> kubectl scale --replicas=9 -f replication-controller.yaml 
master> kubectl get pods -o wide 
master> kubectl scale --replicas=1 replicationcontroller myapp-web
master> kubectl get pods -o wide 

master> wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/replica-set.yaml
master> kubectl create -f replica-set.yaml
master> kubectl get replicaset 
master> kubectl get rs
master> kubectl get pods
master> kubectl get pods -o wide 
master> cat replica-set.yaml 
master> sed -i 's/replicas: 3/replicas: 6/g' replica-set.yaml 
master> cat replica-set.yaml 
master> kubectl replace -f replica-set.yaml 
master> kubectl get rs
master> kubectl get pods -o wide 
master> kubectl scale --replicas=9 -f replica-set.yaml 
master> kubectl get pods -o wide 
master> kubectl scale --replicas=1 replicaset frontend 
master> kubectl get pods -o wide 


master> wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/deployment.yaml
master> kubectl create -f deployment.yaml
master> kubectl get deployment
master> kubectl get rs
master> kubectl get pods 
master> cat deployment.yaml 
master> sed -i 's/replicas: 3/replicas: 6/g' deployment.yaml 
master> cat deployment.yaml 
master> kubectl replace -f deployment.yaml 
master> kubectl get deployment
master> kubectl get pods -o wide 
master> kubectl scale --replicas=9 -f deployment.yaml 
master> kubectl get pods -o wide 
master> kubectl scale --replicas=1 deployment website001 
master> kubectl get pods -o wide


master> kubectl replace -f deployment.yaml
master> kubectl describe deployment website001
master> cat deployment.yaml 
master> sed -i 's/image: nginx/image: nginx:1.23/g' deployment.yaml 
master> cat deployment.yaml 
master> kubectl replace -f deployment.yaml 
master> kubectl rollout status deployment website001
master> kubectl get rs 
master> kubectl rollout history deployment website001
master> kubectl set image deployment website001 web=nginx:1.9.1
master> kubectl rollout status deployment website001
master> kubectl rollout history deployment website001
master> kubectl rollout undo deployment website001
master> kubectl rollout status deployment website001 
master> kubectl rollout history deployment website001
master> kubectl get rs


master> kubectl apply -f https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/node-port.yaml
master> kubectl get svc
master> kubectl describe service website001
Open http://PublicIP:30303

master> kubectl apply -f https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/cluster-ip.yaml
master> kubectl get svc
master> kubectl describe service website001-internal 
master> curl http://10.##.##.##


# Kubectl autocomplete - BASH
source <(kubectl completion bash) 
echo "source <(kubectl completion bash)" >> ~/.bashrc

kubectl get pods --> press the table key 

Ref: https://kubernetes.io/docs/reference/kubectl/cheatsheet/

## Kubernetes setup with Kubespary 
sudo hostnamectl set-hostname controller
sudo apt install python3-pip
git clone https://github.com/kubernetes-sigs/kubespray.git
cd kubespray/
sudo pip install -r requirements.txt
ansible --version
sudo vim /etc/ansible/hosts   ## add your hosts details 
ansible all -m ping

cp -rfp inventory/sample inventory/mycluster
declare -a IPS=(172.31.18.26 172.31.23.152 172.31.31.16 172.31.22.205)
CONFIG_FILE=inventory/mycluster/hosts.yaml python3 contrib/inventory_builder/inventory.py ${IPS[@]}
vim inventory/mycluster/hosts.yaml   ## update your nodes information  
ansible-playbook -i inventory/mycluster/hosts.yaml  --become --become-user=root cluster.yml

master> mkdir .kube 
master> sudo cp /etc/kubernetes/admin.conf .kube/config
master> sudo chown ubuntu:ubuntu .kube/config 
master> kubectl get nodes
master> kubectl get pods -A

## Create Namespace 
kubectl get ns
kubectl get namespace
kubectl get pods -n default
kubectl get pods
kubectl get pods -n kube-system
kubectl create namespace NAME
kubectl get all -n NAME
kubectl run demo --image=nginx -n NAME
kubectl get all -n NAME
kubectl get pods -A

## OVS Deployment 
# Creating configmap 
kubectl create -f https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/ovs/app-configmap.yaml -n NAME 
kubectl get configmap -n NAME
kubectl describe configmap ovs-config -n NAME
kubectl get configmap ovs-config -o yaml -n NAME 

# Postgres Password: echo -n 'password' | base64
kubectl create -f https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/ovs/db-config.yaml -n NAME
kubectl get secret -n NAME
kubectl describe secret postgres-config -n NAME
kubectl get secret postgres-config -o yaml -n NAME

# Postgres deployment with clusterip 
kubectl create -f https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/ovs/postgres-db.yaml -n NAME
kubectl get all -n NAME
kubectl describe svc postgres -n NAME 

# Deployment - adminer 
kubectl create -f https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/ovs/adminer.yaml -n NAME
kubectl get all -n NAME
kubectl describe svc adminer -n NAME
curl node3:NODEPORT 
Open link http://54.215.208.140:NODEPORT  

# Deployment - ovs 
kubectl create -f https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/ovs/ovs-app.yaml -n NAME
kubectl get all -n NAME 
kubectl logs ovs-####-###### -n NAME
kubectl get pods -o wide -n NAME 
kubectl get svc ovs -n NAME
curl node3:NODEPORT 
Open link http://54.215.208.140:NODEPORT/swagger-ui.html  

# PV and PVC 
mkdir ~/NAME
cd ~/NAME
wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/ovs/postgres-storage.yaml
sed -i 's/NAME/jai/g' postgres-storage.yaml ### replace jai with your name 
cat postgres-storage.yaml
kubectl create -f postgres-storage.yaml
kubectl get pv
kubectl get pvc -n NAME
wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/ovs/postgres-db-storage.yaml
sed -i 's/NAME/jai/g' postgres-db-storage.yaml  ### replace jai with your name
cat postgres-db-storage.yaml
kubectl replace -f postgres-db-storage.yaml -n NAME
kubectl get pods -o wide -n NAME | grep postgres
ssh  NODENAME "sudo ls /mnt/data/NAME"

## Monitoring 
wget https://github.com/prometheus-operator/kube-prometheus/archive/refs/tags/v0.10.0.tar.gz
tar xvfz v0.10.0.tar.gz
cd kube-prometheus-0.10.0/
kubectl create -f manifests/setup
kubectl create -f manifests/
kubectl get pods -n monitoring -o wide | grep grafana
curl  POD-IP-ADDRESS:3000
kubectl --namespace monitoring patch svc grafana -p '{"spec": {"type": "NodePort"}}'
kubectl get svc  --namespace monitoring | grep grafana
curl CLUSTER-IP:3000
curl node2:NODEPORT
Open Grafana http://Public-IP-Node:NODEPORT 
  User: admin  Password: admin 
You can import kubernetes dashboard: https://grafana.com/grafana/dashboards/15757-kubernetes-views-global/   


## Add a node to the cluster 
sudo hostnamectl set-hostname INSTANCE-NAME 
# refresh your session 
wget https://raw.githubusercontent.com/Jaibw/docker/main/install_k8s_worker_ubuntu_20.04.sh
sh install_k8s_worker_ubuntu_20.04.sh
sudo kubeadm join 172.31.26.230:6443 --token v3t4po.sb80f2rr6jb1tf9e --discovery-token-ca-cert-hash sha256:a223781a3ee9cf383f6c162f8b6c675203a498d93fe205da0a39d43fbd3ab34d

## Remove node from cluster 
master> kubectl get nodes
master> kubectl drain NODE-NAME --delete-local-data --ignore-daemonsets
master> kubectl get nodes
master> kubectl get pods -o wide
master> kubectl cordon NODE-NAME
master> kubectl delete node NODE-NAME
master> kubectl get nodes

## EKSCTL 
sudo apt update
sudo apt  install awscli
aws confiure
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
sudo apt -y install curl apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt update
sudo apt -y install vim git curl wget kubectl=1.20.15-00
kubectl version --client
eksctl version
eksctl create cluster --name demo01 --region us-west-1
mkdir ~/.kube
aws eks update-kubeconfig --region us-west-1 --name demo01
kubectl  get nodes

## Loadbalancer demo 
controller> mkdir ~/NAME
controller> cd ~/NAME
controller> wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/loadbalancer-demo.yaml
controller> sed -i 's/username/NAME/g' loadbalancer-demo.yaml
controller> cat loadbalancer-demo.yaml
controller> kubectl get all
controller> kubectl create -f loadbalancer-demo.yaml
controller> kubectl get all
controller> kubectl describe pod web-NAME-####-####
controller> kubectl describe svc web-NAME
controller> kubectl get svc web-NAME
Open link http://######.us-west-1.elb.amazonaws.com/

## Ingress demo 
controller> mkdir ~/NAME
controller> cd ~/NAME
controller> wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/k8s/ingress-demo.yaml
controller> sed -i 's/username/NAME/g' ingress-demo.yaml
controller> cat ingress-demo.yaml
controller> kubectl create -f ingress-demo.yaml
controller> kubectl get all | grep NAME 
controller> kubectl get ingress | grep NAME
Open link http://a1de81a94f6184a68a5b4c572b44dbeb-1f8388d56e3c7df0.elb.us-west-1.amazonaws.com/NAME


## Apache Kafka using Docker Compose 

wget https://raw.githubusercontent.com/Jaibw/docker-v1/master/docker-compose/apache-kafka.yaml

mv apache-kafka.yaml docker-compose.yml 
docker-compose up -d

docker exec broker kafka-topics --bootstrap-server broker:9092 --create --topic quickstart

docker exec --interactive --tty broker kafka-console-producer --bootstrap-server broker:9092 --topic quickstart
# type the message and press Ctrl + D to exit

docker exec --interactive --tty broker kafka-console-consumer --bootstrap-server broker:9092 --topic quickstart  --from-beginning  
# wait for some time and press Ctrl + C to exit

docker-compose down 


## Install OpenShift 
wget https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
tar xvf openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
cd openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit/
sudo mv  oc kubectl  /usr/local/bin/
cd ~
oc version

docker stop `docker ps -q`
docker rm `docker ps -qa`
docker system prune --all 
docker volume prune 
sudo vim /etc/systemd/system/multi-user.target.wants/docker.service
## Update … dockerd --insecure-registry=172.30.0.0/16 …
sudo systemctl daemon-reload
sudo systemctl restart docker

oc --help
oc cluster up
oc login -u system:admin
docker images
docker ps
docker ps | grep redis 
oc new-app --docker-image=registry.hub.docker.com/library/redis --name=redis
oc get pods
oc get svc
docker ps | grep redis 

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published