Skip to content
Snippets Groups Projects
Commit 39752fcc authored by Barbara Martelli's avatar Barbara Martelli
Browse files

Add new file

parent 14ac2a3c
No related branches found
No related tags found
No related merge requests found
# Get minikube:
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.30.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
# Get kubectl
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 && mv ./kubectl /usr/local/bin/kubectl
#Config:
echo "`hostname -i` minikube" >> /etc/hosts
# echo “[host eth0 IP] [hostname] [hostname.novalocal]” >> /etc/hosts
#Run:
minikube config set vm-driver none
minikube start
#Verify:
kubectl cluster-info
kubectl get componentstatus
kubectl get nodes
kubectl get pods --all-namespaces
kubectl get deployment --all-namespaces
#Demo kubernetes
minikube version
minikube start
kubectl version
kubectl cluster-info
kubectl get nodes
#Using kubectl to Create a Deployment
#Deploy our app
kubectl run kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1 --port=8080
kubectl get deployments
#View our app
#in a different terminal type:
kubectl proxy
curl http://localhost:8001/version
export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'); echo Name of the Pod: $POD_NAME
curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy/
#Pods and Nodes
#Check application configuration
kubectl get pods
kubectl describe pods
#View the container logs
kubectl logs $POD_NAME
#Executing command on the container
kubectl exec $POD_NAME env
kubectl exec -ti $POD_NAME bash
cat server.js
#You can check that the application is up by running a curl command:
curl localhost:8080
#Note: here we used localhost because we executed the command inside the NodeJS container
#To close your container connection type exit
#Using a Service to Expose Your App
#Create a new service
kubectl get pods
kubectl get services
kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080
kubectl get services
kubectl describe services/kubernetes-bootcamp
#Create an environment variable called NODE_PORT that has the value of the Node port assigned:
export NODE_PORT=$(kubectl get services/kubernetes-bootcamp -o go-template='{{(index .spec.ports 0).nodePort}}'); echo NODE_PORT=$NODE_PORT
curl $(minikube ip):$NODE_PORT
#Using labels
kubectl describe deployment
kubectl get pods -l run=kubernetes-bootcamp
kubectl get services -l run=kubernetes-bootcamp
kubectl label pod $POD_NAME app=v1
kubectl describe pods $POD_NAME
kubectl get pods -l app=v1
#Deleting a service
kubectl delete service -l run=kubernetes-bootcamp
kubectl get services
curl $(minikube ip):$NODE_PORT
kubectl exec -ti $POD_NAME curl localhost:8080
#Running Multiple Instances of Your App
#Scaling a deployment
kubectl get deployments
kubectl scale deployments/kubernetes-bootcamp --replicas=4
kubectl get deployments
kubectl get pods -o wide
kubectl describe deployments/kubernetes-bootcamp
#Load Balancing
#Ricreo il servizio che prima ho cancellato per esercizio:
kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080
kubectl describe services/kubernetes-bootcamp
export NODE_PORT=$(kubectl get services/kubernetes-bootcamp -o go-template='{{(index .spec.ports 0).nodePort}}'); echo NODE_PORT=$NODE_PORT
curl $(minikube ip):$NODE_PORT
#Scale Down
kubectl scale deployments/kubernetes-bootcamp --replicas=2
kubectl get deployments
kubectl get pods -o wide
#Performing a Rolling Update
#Update the version of the app
kubectl get deployments
kubectl get pods
kubectl describe pods
kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=jocatalin/kubernetes-bootcamp:v2
kubectl get pods
#Verify an update
curl $(minikube ip):$NODE_PORT
kubectl rollout status deployments/kubernetes-bootcamp
kubectl describe pods
#Rollback an update
kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=gcr.io/google-samples/kubernetes-bootcamp:v10
kubectl get deployments
kubectl get pods
kubectl describe pods
kubectl rollout undo deployments/kubernetes-bootcamp
kubectl get pods
kubectl describe pods
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment