Kubernetes
Features of an orchestration system
Understanding pods in Kubernetes
Cont 1
Cont 2
Cont 3
Cont 4
Pod 1
Pod 2
Node 1
Kubenetes Cluster
Steps to install minikube on ubuntu
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
sudo dpkg -i minikube_latest_amd64.deb
minikube start
/* while running this command if you get the instruction to add the docker group
then run the command
usermod -aG docker $USER && newgrp docker
and re run command minikube start*/
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
kubectl get pods -A
Steps to install minikube and Kubectl on mac
brew install minikube
brew install kubectl
Test your setup
minikube start
kubectl get po -A
Microservice code
package com.kuberneteswithspringboot.demo.kubenetesspringboot;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@SpringBootApplication
@RestController
public class KubernetesSpringBootApplication {
@Value("${app.version}")
String appVersion;
@GetMapping("/")
public String index() throws IOException {
String returnString= "Spring Boot App "+ appVersion;
String cmd = "cat /proc/self/cgroup | grep name";
Runtime run = Runtime.getRuntime();
Process pr = run.exec(cmd);
try {
pr.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line = " ";
if (( line=buf.readLine())!=null) {
returnString+=line;
}
return returnString;
}
public static void main(String[] args) {
SpringApplication.run(KubernetesSpringBootApplication.class, args);
}
}
Image we will use for the demo purpose
https://hub.docker.com/repository/registry-1.docker.io/pulkitpushkarna/kubernetes-with-spring-boot
Creating your first pod
kubectl run firstpod --image=pulkitpushkarna/kubernetes-with-spring-boot:v1
List pods
kubectl get pods
Describe pod
kubectl describe pod firstpod
kubectl exec -it firstpod -- /bin/bash
Going inside the pod
Delete the pod
kubectl delete pod firstpod
Create Pod using yaml file
kind: Pod
apiVersion: v1
metadata:
name: firstpod
labels:
app: fp
release: stable
spec:
containers:
- name: webapp
image: pulkitpushkarna/kubernetes-with-spring-boot:v1
kubectl create -f firstpod.yaml
firstpod.yaml
Deleting the pods which were created via yaml file
kubectl delete -f firstpod.yaml
POD lifecycle
Display all labels
kubectl get all --show-labels
Filter pods for matching labels
kubectl get all --selector='app=fp'
Filter pods for matching labels negation
kubectl get all --selector='app!=fp'
kubectl get all --selector='app in (fp)'
Using in operator for filteration
Annotations
kind: Pod
apiVersion: v1
metadata:
name: firstpod
labels:
app: fp
release: stable
annotations:
dockerHubUrl: "https://github.com/pulkitpushkarna/kubernetes-spring-boot.git"
logDir: "etc/logs"
spec:
containers:
- name: webapp
image: pulkitpushkarna/kubernetes-with-spring-boot:v1
Namespace
kubectl get ns
kubectl create ns firstns
kubectl create -f firstpod.yaml --namespace firstns
Now if you try to get pods in default namespace it will say no resources found
kubectl get pods
Now check for the pods within first ns namespace
kubectl get pods --namespace firstns
View the default namespace
kubectl config view
Change the default namespace
kubectl config set-context --current --namespace firstns
Now if you try to get pods you will get the pods within firstns namespace
Handy commands
kubectl get all
kubectl create -f firstpod.yaml --dry-run=client
kubectl explain pods
kubectl explain deployments
kubectl get pod/firstpod -o yaml
Kubernetes Deployment Object
apiVersion: apps/v1
kind: Deployment
metadata:
name: mywebserver
labels:
app: spring-boot-app
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
app: spring-boot-app
template:
metadata:
labels:
app: spring-boot-app
spec:
containers:
- name: my-spring-boot-app
image: pulkitpushkarna/kubernetes-with-spring-boot:v1
ports:
- containerPort: 8080
webserver.yaml
Create deployment object
kubectl create -f webserver.yaml
Get all the objects
kubectl get all
Get deployment objects
kubectl get deployment
kubectl get pod
Get pod objects
kubernetes service Object
Client
Cluster IP Service
Pod A
Pod B
Pod C
Node Port Service
30000 to 32767
apiVersion: v1
kind: Service
metadata:
name: webserver-service
spec:
type: NodePort
selector:
app: spring-boot-app
ports:
- nodePort: 30123
port: 8080
targetPort: 8080
webservice-service.yaml
kubectl create -f webserver-service.yaml
Create the service using the command below
kubectl get services
Get services
Start tunnel for service
minikube service webserver-service -n firstns
Now the url which is opened on your browser use the same on your console using curl command to see the load balancing.
Update strategy for updating image
apiVersion: apps/v1
kind: Deployment
metadata:
name: mywebserver
labels:
app: spring-boot-app
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
app: spring-boot-app
template:
metadata:
labels:
app: spring-boot-app
spec:
containers:
- name: my-spring-boot-app
image: pulkitpushkarna/kubernetes-with-spring-boot:v2
ports:
- containerPort: 8080
In the spec section you can see the strategy for updating the deployment
Checkout to branch V2 of the application
Update the deployment with V2
kubectl replace -f webserver.yaml
git checkout v2
Now start hitting the following commands multiple times to observe different stages of the pods
kubectl get pods
Get the description of the deployment
kubectl describe deployment mywebserver -n firstns
Rollback to a previous revision
View revision history
kubectl rollout history deployment
View details of a revision
kubectl rollout history deployment mywebserver --revision=2
Roll back to previous revision
kubectl rollout undo deployment mywebserver --to-revision=1
Run following command multiple times to track the progress of pods
kubectl get pods
Manually scale replicas
kubectl scale deployment mywebserver --replicas=10
Checkout ready pods
kubectl get deployments
Check the state of the pods
kubectl get pods
Autoscaling with horizontal pod autoscaler
kubectl autoscale deployment mywebserver --cpu-percent=50 --min=1 --max=10
kubectl get hpa
Exercise 1
Volumes in Kubernetes
Types of volume:
hostPath Mounting
kubectl create -f webserver.yaml
pulkit-pushkarna kubenetes-spring-boot % kubectl get pod
NAME READY STATUS RESTARTS AGE
mywebserver-847df9fdcb-8q4cb 1/1 Running 0 67s
mywebserver-847df9fdcb-rjd4g 1/1 Running 0 67s
pulkit-pushkarna kubenetes-spring-boot % kubectl exec -it mywebserver-847df9fdcb-8q4cb -- /bin/bash
root@mywebserver-847df9fdcb-8q4cb:/usr/local/bin# cd /data/
root@mywebserver-847df9fdcb-8q4cb:/data# touch hello.html
pulkitpushkarna@pulkit-pushkarna kubenetes-spring-boot % minikube ssh
docker@minikube:~$ cd /data
docker@minikube:/data$ ls
hello.html
docker@minikube:/data$
apiVersion: apps/v1
kind: Deployment
metadata:
name: mywebserver
labels:
app: spring-boot-app
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
app: spring-boot-app
template:
metadata:
labels:
app: spring-boot-app
spec:
containers:
- name: my-spring-boot-app
image: pulkitpushkarna/kubernetes-with-spring-boot:v2
ports:
- containerPort: 8080
volumeMounts:
- name: demovol
mountPath: /data
volumes:
- name: demovol
hostPath:
path: /data
type: Directory
Mounting Config Map
apiVersion: v1
kind: ConfigMap
metadata:
name: demo-configmap
data:
initdb.sql:
create table person();
key:
kasdkjajksdkj
apiVersion: apps/v1
kind: Deployment
metadata:
name: mywebserver
labels:
app: spring-boot-app
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
app: spring-boot-app
template:
metadata:
labels:
app: spring-boot-app
spec:
containers:
- name: my-spring-boot-app
image: pulkitpushkarna/kubernetes-with-spring-boot:v2
ports:
- containerPort: 8080
volumeMounts:
- name: demovol
mountPath: /data
- name: config-map-vol
mountPath: /etc/config
volumes:
- name: demovol
hostPath:
path: /data
type: Directory
- name: config-map-vol
configMap:
name: demo-configmap
kubectl create -f config-map.yaml
kubectl create -f webserver.yaml
kubectl get configMap
pulkit-pushkarna kubenetes-spring-boot % kubectl get pod
NAME READY STATUS RESTARTS AGE
mywebserver-79df4d5d54-qvglq 1/1 Running 0 10s
mywebserver-79df4d5d54-tgvgc 1/1 Running 0 10s
pulkit-pushkarna kubenetes-spring-boot % kubectl exec -it mywebserver-79df4d5d54-qvglq -- /bin/bash
root@mywebserver-79df4d5d54-qvglq:/usr/local/bin# cd /etc/config/
root@mywebserver-79df4d5d54-qvglq:/etc/config# ls
initdb.sql key
root@mywebserver-79df4d5d54-qvglq:/etc/config# cat initdb.sql
create table person();
root@mywebserver-79df4d5d54-qvglq:/etc/config# cat key
kasdkjajksdkj
Mounting Secret
apiVersion: v1
kind: Secret
metadata:
name: demo-secret
type: Opaque
data:
username:
U2VjcmV0VXNlcm5hbWUK
password:
U2VjcmV0UGFzc3dvcmQK
pulkit-pushkarna kubenetes-spring-boot % echo "SecretUsername" | base64
U2VjcmV0VXNlcm5hbWUK
pulkit-pushkarna kubenetes-spring-boot % echo "SecretPassword" | base64
U2VjcmV0UGFzc3dvcmQK
apiVersion: apps/v1
kind: Deployment
metadata:
name: mywebserver
labels:
app: spring-boot-app
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
app: spring-boot-app
template:
metadata:
labels:
app: spring-boot-app
spec:
containers:
- name: my-spring-boot-app
image: pulkitpushkarna/kubernetes-with-spring-boot:v2
ports:
- containerPort: 8080
volumeMounts:
- name: demovol
mountPath: /data
- name: config-map-vol
mountPath: /etc/config
- name: my-secret
mountPath: /etc/mysecrets
volumes:
- name: demovol
hostPath:
path: /data
type: Directory
- name: config-map-vol
configMap:
name: demo-configmap
- name: my-secret
secret:
secretName: demo-secret
volumeMounts:
- name: demovol
mountPath: /data
- name: config-map-vol
mountPath: /etc/config
- name: my-secret
mountPath: /etc/mysecrets
volumes:
- name: demovol
hostPath:
path: /data
type: Directory
- name: config-map-vol
configMap:
name: demo-configmap
- name: my-secret
secret:
secretName: demo-secret
kubectl create -f secrets.yaml
kubectl create -f webserver.yaml
pulkit-pushkarna kubenetes-spring-boot % kubectl get pod
NAME READY STATUS RESTARTS AGE
mywebserver-77b4c6d9b5-7p6jv 1/1 Running 0 17s
mywebserver-77b4c6d9b5-vkdz2 1/1 Running 0 17s
pulkit-pushkarna kubenetes-spring-boot % kubectl exec -it mywebserver-77b4c6d9b5-7p6jv -- /bin/bash
root@mywebserver-77b4c6d9b5-7p6jv:/usr/local/bin# cd /etc
root@mywebserver-77b4c6d9b5-7p6jv:/etc# cd mysecrets/
root@mywebserver-77b4c6d9b5-7p6jv:/etc/mysecrets# ls
password username
root@mywebserver-77b4c6d9b5-7p6jv:/etc/mysecrets# cat password
SecretPassword
root@mywebserver-77b4c6d9b5-7p6jv:/etc/mysecrets# cat username
SecretUsername
emptyDir mounting
apiVersion: apps/v1
kind: Deployment
metadata:
name: mywebserver
labels:
app: spring-boot-app
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
app: spring-boot-app
template:
metadata:
labels:
app: spring-boot-app
spec:
containers:
- name: my-spring-boot-app
image: pulkitpushkarna/kubernetes-with-spring-boot:v2
ports:
- containerPort: 8080
volumeMounts:
- name: demovol
mountPath: /data
- name: config-map-vol
mountPath: /etc/config
- name: my-secret
mountPath: /etc/mysecrets
- name: cache-volume
mountPath: /cache
volumes:
- name: demovol
hostPath:
path: /data
type: Directory
- name: config-map-vol
configMap:
name: demo-configmap
- name: my-secret
secret:
secretName: demo-secret
- name: cache-volume
emptyDir: {}
volumeMounts:
- name: demovol
mountPath: /data
- name: config-map-vol
mountPath: /etc/config
- name: my-secret
mountPath: /etc/mysecrets
- name: cache-volume
mountPath: /cache
volumes:
- name: demovol
hostPath:
path: /data
type: Directory
- name: config-map-vol
configMap:
name: demo-configmap
- name: my-secret
secret:
secretName: demo-secret
- name: cache-volume
emptyDir: {}
Persistent volumes
Access Modes
Create Persistent Volume
apiVersion: v1
kind: PersistentVolume
metadata:
name: demo-persistent-volume
spec:
capacity:
storage: 128M
accessModes:
- ReadWriteOnce
hostPath:
path: /my-peristent-volume
kubectl create -f persistent-volume.yaml
kubectl get pv
Create Persistent Volume Claim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: demo-pvc
spec:
resources:
requests:
storage: 64M
accessModes:
- ReadWriteOnce
kubectl create -f persistent-volume-claim.yaml
kubectl get pvc
mounting permanent volume
apiVersion: apps/v1
kind: Deployment
metadata:
name: mywebserver
labels:
app: spring-boot-app
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
app: spring-boot-app
template:
metadata:
labels:
app: spring-boot-app
spec:
containers:
- name: my-spring-boot-app
image: pulkitpushkarna/kubernetes-with-spring-boot:v2
ports:
- containerPort: 8080
volumeMounts:
- name: demovol
mountPath: /data
- name: config-map-vol
mountPath: /etc/config
- name: my-secret
mountPath: /etc/mysecrets
- name: cache-volume
mountPath: /cache
- name: demo-pvc
mountPath: /clusterVol
volumes:
- name: demovol
hostPath:
path: /data
type: Directory
- name: config-map-vol
configMap:
name: demo-configmap
- name: my-secret
secret:
secretName: demo-secret
- name: cache-volume
emptyDir: {}
- name: demo-pvc
persistentVolumeClaim:
claimName: demo-pvc
volumeMounts:
- name: demovol
mountPath: /data
- name: config-map-vol
mountPath: /etc/config
- name: my-secret
mountPath: /etc/mysecrets
- name: cache-volume
mountPath: /cache
- name: demo-pvc
mountPath: /clusterVol
volumes:
- name: demovol
hostPath:
path: /data
type: Directory
- name: config-map-vol
configMap:
name: demo-configmap
- name: my-secret
secret:
secretName: demo-secret
- name: cache-volume
emptyDir: {}
- name: demo-pvc
persistentVolumeClaim:
claimName: demo-pvc
Delete the existing deployment and create a new deployment using webserver.yaml file
kubectl delete -f webserver.yaml
kubectl create -f webserver.yaml
pulkitpushkarna@pulkit-pushkarna kubenetes-spring-boot % kubectl get pods
NAME READY STATUS RESTARTS AGE
mywebserver-86d5f67d78-dkgrg 1/1 Running 0 8s
mywebserver-86d5f67d78-zntw6 1/1 Running 0 8s
pulkitpushkarna@pulkit-pushkarna kubenetes-spring-boot % kubectl exec -it mywebserver-86d5f67d78-dkgrg -- /bin/bash
root@mywebserver-86d5f67d78-dkgrg:/usr/local/bin# cd /clusterVol/
root@mywebserver-86d5f67d78-dkgrg:/clusterVol# touch hello.html
kubectl delete all --all
Exercise 2
Creating a cluster of SpringBoot App with Mysql database
apiVersion: apps/v1
kind: Deployment
metadata:
name: docker-mysql
labels:
app: docker-mysql
spec:
replicas: 1
selector:
matchLabels:
app: docker-mysql
template:
metadata:
labels:
app: docker-mysql
spec:
containers:
- name: docker-mysql
image: mysql
env:
- name: MYSQL_DATABASE
value: mydb
- name: MYSQL_ROOT_PASSWORD
value: test1234
- name: MYSQL_ROOT_HOST
value: '%'
docker-mysql-deployment.yaml
We need to have a service to expose ports of mysql docker-mysql-service.yaml
apiVersion: v1
kind: Service
metadata:
name: docker-mysql
labels:
app: docker-mysql
spec:
selector:
app: docker-mysql
type: NodePort
ports:
- port: 3306
targetPort: 3306
nodePort: 30287
For the Spring Boot App image deployed on Kubernetes inside a pod we need to provide different application properties. podApplicationConfigFile/application.properties
app.version=externalPropertiesFile
spring.datasource.url=jdbc:mysql://docker-mysql:3306/mydb
spring.datasource.username=root
spring.datasource.password=test1234
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=create
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
server.port=9091
You must have observed that in the datasource url we have specified docker-mysql which is name of the mysql container
We will gonna create a configMap for the properties file
kubectl create configmap spring-app-config --from-file=podApplicationConfigFile/application.properties
Checkout the configMap
kubectl get configMap
Checkout the YAML created by the command kubectl command
kubectl get configMap spring-app-config -o yaml
Now inside the webserver.yaml file we will mount spring-app-config ConfigMap
apiVersion: apps/v1
kind: Deployment
metadata:
name: mywebserver
labels:
app: spring-boot-app
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
app: spring-boot-app
template:
metadata:
labels:
app: spring-boot-app
spec:
containers:
- name: my-spring-boot-app
image: pulkitpushkarna/kubernetes-with-spring-boot:v4
ports:
- containerPort: 8080
volumeMounts:
- name: demovol
mountPath: /data
- name: config-map-vol
mountPath: /etc/config
- name: my-secret
mountPath: /etc/mysecrets
- name: cache-volume
mountPath: /cache
- name: demo-pvc
mountPath: /clusterVol
- name: application-config
mountPath: /appConfigFile
volumes:
- name: demovol
hostPath:
path: /data
type: Directory
- name: config-map-vol
configMap:
name: demo-configmap
- name: my-secret
secret:
secretName: demo-secret
- name: cache-volume
emptyDir: {}
- name: demo-pvc
persistentVolumeClaim:
claimName: demo-pvc
- name: application-config
configMap:
name: spring-app-config
Create MySQL deployment
kubectl create -f docker-mysql-deployment.yaml
Create MySQL service
kubectl create -f docker-mysql-service.yaml
Create deployment for web app
kubectl create -f webserver.yaml
Get pods
kubectl get pod
Check the logs of one of the pod from WebApp Deployment
kubectl logs mywebserver-7dffbdcfbb-6k95x
if you go inside the port you will see that the application.properties in mounted on the folder /appConfigFile
pulkit-pushkarna kubenetes-spring-boot % kubectl exec -it mywebserver-7dffbdcfbb-6k95x -- /bin/bash
root@mywebserver-7dffbdcfbb-6k95x:/usr/local/bin# cd /appConfigFile/
root@mywebserver-7dffbdcfbb-6k95x:/appConfigFile# ls
application.properties
root@mywebserver-7dffbdcfbb-6k95x:/appConfigFile#
root@mywebserver-7dffbdcfbb-6k95x:/appConfigFile# cat application.properties
app.version=externalPropertiesFile
spring.datasource.url=jdbc:mysql://docker-mysql:3306/mydb
spring.datasource.username=root
spring.datasource.password=test1234
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=create
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
server.port=9091root@mywebserver-7dffbdcfbb-6k95x:/appConfigFile#
Perfom curl command inside the container
root@mywebserver-7dffbdcfbb-6k95x:/appConfigFile# curl localhost:9091
Spring Boot App--externalPropertiesFile14:name=systemd:/docker/e5008bbd7f2b3ce3aabdbc921fb444258c0afdfaa62b0954c974ff6b8b31cc9b/kubepods/besteffort/pode7809864-c537-47a7-bfe9-fd08c33c39cf/e83dc09b0d71cce137de038ce7c498f27ac3c2e96e227b823cdf0abe0d7e3a1c
Running kubernetes cluster on EKS
Exercise 3
Create kubernetes Cluster
eksctl create cluster --name my-kube-cluster --node-type t2.micro --nodes 2 --nodes-min 2 --nodes-max 3
Checkout to branch v1 and execute webserver.yaml
kubectl create -f webserver.yaml
You will observer that 2 instances are created in aws. You can also list the pods and check the deployment object.
kubectl get pods
kubectl get deployment
In order to to expose our app to the outside world we need to create a load balancer by execute the following command.
kubectl expose deploy mywebserver --type=LoadBalancer --port=8080
pulkitpushkarna@pulkit-pushkarna kubenetes-spring-boot % kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 18m
mywebserver LoadBalancer 10.100.158.212 a029f7f1279bb42b886f03428e5a3551-2144999605.us-west-2.elb.amazonaws.com 8080:30824/TCP 41s
To get the url of the load balancer execute following command
use the url mentioned in the external IP column and prepend :8080 to it. You will see the load balancing between 2 nodes.
pulkitpushkarna@pulkit-pushkarna kubenetes-spring-boot % curl a029f7f1279bb42b886f03428e5a3551-2144999605.us-west-2.elb.amazonaws.com:8080
Spring Boot App v1--11:pids:/kubepods/besteffort/pod025ad0e8-93fd-4716-af56-ee002d27e515/a12d547cc0e521bfd52502eab3a036e0a8408d39607f5af9174adab144e76184% pulkitpushkarna@pulkit-pushkarna kubenetes-spring-boot % curl a029f7f1279bb42b886f03428e5a3551-2144999605.us-west-2.elb.amazonaws.com:8080
Spring Boot App v1--11:pids:/kubepods/besteffort/pod025ad0e8-93fd-4716-af56-ee002d27e515/a12d547cc0e521bfd52502eab3a036e0a8408d39607f5af9174adab144e76184% pulkitpushkarna@pulkit-pushkarna kubenetes-spring-boot % curl a029f7f1279bb42b886f03428e5a3551-2144999605.us-west-2.elb.amazonaws.com:8080
Spring Boot App v1--11:pids:/kubepods/besteffort/pod025ad0e8-93fd-4716-af56-ee002d27e515/a12d547cc0e521bfd52502eab3a036e0a8408d39607f5af9174adab144e76184% pulkitpushkarna@pulkit-pushkarna kubenetes-spring-boot % curl a029f7f1279bb42b886f03428e5a3551-2144999605.us-west-2.elb.amazonaws.com:8080
Spring Boot App v1--11:hugetlb:/kubepods/besteffort/poda2192d56-165c-47b0-b1dd-1ffd08cfb0df/e306da51cae5a644756d32a6bc72c37cfbf574b396f8655e04f53581fe2b5339%
kubectl replace -f webserver.yaml
kubectl rollout history deployment
kubectl rollout undo deployment mywebserver --to-revision=1
Mounting EBS for persistent storage
aws ec2 describe-availability-zones
aws ec2 create-volume --availability-zone=us-west-2a --size=10 --volume-type=gp2
kubectl delete pv demo-persistent-volume
kubectl create -f persistent-volume.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: demo-persistent-volume
spec:
capacity:
storage: 128M
accessModes:
- ReadWriteOnce
awsElasticBlockStore:
fsType: ext4
volumeID: vol-040ab6d057f6f1624
kubectl delete pvc demo-pvc
kubectl create -f persistent-volume-claim.yaml
\
kubectl create -f webserver.yaml
Cleaning up the resources
eksctl delete cluster --name my-kube-cluster
Also delete the EBS volume which you have created for persistent volume