$ curl -L https://github.com/kubernetes-sigs/kind/releases/download/v0.8.1/kind-linux-amd64 -o kind
$ chmod +x ./kind
$ sudo mv ./kind /usr/local/bin/kind
- Update existing listed packages
$ sudo apt update
- Install a few prerequisite packages which let apt use packages over HTTPS.
$ sudo apt install apt-transport-https ca-certificates curl software-properties-common
- Then add the GPG key for the official Docker repository to system.
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- Add the Docker repository to APT sources
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
- Update the package database with the Docker packages from the newly added repo
$ sudo apt update
- Install from the Docker repo instead of the default Ubuntu repo
$ apt-cache policy docker-ce
- Install docker
$ sudo apt install docker-ce
- Checked Docker installed
$ sudo systemctl status docker
$ curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt` /bin/linux/amd64/kubectl
$ chmod +x ./kubectl
- Create the File using this content adn with yaml extension
$ echo "" >> kind.config.yaml
kind: Cluster apiVersion: kind.sigs.k8s.io/v1alpha3 nodes:
- role: control-plane
extraPortMappings:
- containerPort: 30080 hostPort: 80 listenAddress: "0.0.0.0" protocol: TCP
- role: worker1
- role: worker2
- Create cluster using Kind command , The extra port mapping is required to allow us to talk to the webserver
$ kind create cluster --name mycluster --config kind.config.yaml --wait 5m
- Cluster is created , Using following command check the cluster
$ sudo kind get clusters
- Create deployment file with extension .yaml
apiVersion: apps/v1 kind: Deployment metadata: labels: app: example1 name: example1 spec: replicas: 1 selector: matchLabels: app: example1 template: metadata: labels: app: example1 spec: containers: - image: nginx:latest name: nginx ports: - containerPort: 80 name: nginx
$ sudo kubectl apply -f helloworld.yaml
- Check pod is up and running
$ sudo kubectl get pods
- Check logs of th ppod
$ sudo kubectl logs (pod name)
- Create service file first
$ echo "apiVersion: v1 >> helloservice.yaml kind: Service metadata: name: helloworld labels: app: helloworld spec: type: NodePort selector: app: helloworld ports: - protocol: TCP targetPort: 80 port: 80 nodePort: 30080"
- Apply service
$ sudo kubectl apply -f helloservice.yaml
- Check services using following command
$ sudo kubectl get services
- Now check using curl command on localhost nginx is running
$ sudo curl localhost
1)Enter in the running pod using following command
$ sudo kubectl exec -it $podname bash
- Under pod go to the path /usr/share/nginx/html
$ cd /usr/share/nginx/html
- change the content of a index.html file
$ echo "hello world" >> index.html
- check using curl commadn on host machine content is change or not .
$ curl localhost
- launch Ubuntu 18.04 free tier instance and configure it and run the script on it .