k8s and minikube
Environment: Debian Linux 9, Linux kernel virtual machines, Docker.
KVM: virsh list
# virsh list Id Name State ---------------------------------------------------- 1 c7web01 running 2 c7dotnet running 6 c8backend running 32 minikube running
kube status
# minikube status minikube type: Control Plane host: Running kubelet: Running apiserver: Running kubeconfig: Configured
kube service list
# minikube service list |-------------|------------|--------------|-----| | NAMESPACE | NAME | TARGET PORT | URL | |-------------|------------|--------------|-----| | default | kubernetes | No node port | | kube-system | kube-dns | No node port | |-------------|------------|--------------|-----|
kube nodes
# kubectl get nodes NAME STATUS ROLES AGE VERSION minikube Ready control-plane 11m v1.25.0
minikube ssh
# minikube ssh _ _ _ _ ( ) ( ) ___ ___ (_) ___ (_)| |/') _ _ | |_ __ /' _ ` _ `\| |/' _ `\| || , < ( ) ( )| '_`\ /'__`\ | ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )( ___/ (_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____) $ hostname minikube
create pod
# kubectl create deployment nginx --image=nginx deployment.apps/nginx created
get pods
# kubectl get pods NAME READY STATUS RESTARTS AGE nginx-12345abcd-hoge1 0/1 ContainerCreating 0 7s
expose and deployment pod
# kubectl expose deployment nginx --type="NodePort" --port 80 service/nginx exposed
get services
# kubectl get services nginx NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE nginx NodePort local-ipaddr80:31977/TCP 22s
get service url
# minikube service nginx --url http://local-ip-addr:listen-port
scaling
# kubectl scale deployment nginx --replicas=2 deployment.apps/nginx scaled # kubectl get pods NAME READY STATUS RESTARTS AGE nginx-12345abcd-hoge1 1/1 Running 0 4m49s nginx-12345abde-hoge2 0/1 ContainerCreating 0 5s
check behavior
# curl http://local-ip-addr:listen-port <!DOCTYPE html> <body> <head> <title>Welcome to nginx!</title> </head> <h1>Welcome to nginx!</h1> </body>
check log
# kubectl logs nginx-12345abcd-hoge1|grep GET 172.17.0.1 - - [DD/Mon/YYYY:HH:MM:SS +0000] "GET / HTTP/1.1" 200 615 "-" "curl/7.52.1" "-"