+
Skip to content

rbrayner/k8s-demo

Repository files navigation

k8s-demo

1. Objective

This repository aims to help kubernetes beginners to learn the basics with very simple examples obtained from many sources. I have created a Makefile to simplify the example's execution.

2. Requirements

  • Linux or MacOS
  • docker
  • kubectl
  • curl
  • make
  • kind (kind.io)

Install kind and execute the following command to start a kubernetes cluster:

make start
make list

3. Examples

3.1. Create a single pod

make 1-pods
kubectl get pods
kubectl delete pod hello
kubectl get pods

3.2. Create a service to the pod

make 2-services
kubectl get pods,svc
curl localhost:31000
kubectl delete pod hello
curl localhost:31000
kubectl delete svc hello

3.3. Create a deployment

make 3-deployments
kubectl get pods,svc
curl localhost:31000
kubectl delete pods -l app=hello
curl localhost:31000
kubectl delete svc hello
kubectl delete deploy hello

3.4. Scale the application

make 4-replicas
kubectl get pods,svc
curl localhost:31000
kubectl delete svc hello
kubectl delete deploy hello

3.5. Update with recreate strategy

make 5-updates-recreate
kubectl get pods,svc
curl localhost:31000
kubectl set image deployment/hello hello-from=pbitty/hello-from:error
kubectl get pods
kubectl get replicasets
curl localhost:31000
kubectl rollout status deployment/hello
kubectl rollout history deploy/hello
kubectl rollout history deploy/hello --revision=2
kubectl rollout history deploy/hello --revision=1
kubectl rollout undo deployment/hello --to-revision 1
kubectl rollout status deployment/hello
curl localhost:31000
kubectl delete svc hello
kubectl delete deploy hello

3.6. Update with rollingUpdate strategy

make 5-updates-rolling
kubectl get pods,svc
curl localhost:31000
kubectl set image deployment/hello hello-from=pbitty/hello-from:error
kubectl get pods
kubectl get replicasets
curl localhost:31000
kubectl rollout status deployment/hello
kubectl rollout history deploy/hello
kubectl rollout history deploy/hello --revision=2
kubectl rollout history deploy/hello --revision=1
kubectl rollout undo deployment/hello --to-revision 1
kubectl rollout status deployment/hello
curl localhost:31000
kubectl delete svc hello
kubectl delete deploy hello

4. Cleanup

The following command deletes the cluster:

make stop

5. Sources

https://kubernetes.io/

https://minikube.sigs.k8s.io/docs/tutorials/multi_node/

https://kind.sigs.k8s.io/docs/user/ingress/#ingress-nginx

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载