lan1note

[kubernetes] Cài đặt kubectl, minikube – Run hello-world

Cài đặt kubectl, minikube và chạy hello-world

Môi trường thực thi: Centos 7.6

1| Cài đặt kubectl

$ curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.15.1/bin/linux/amd64/kubectl
$ chmod +x ./kubectl
$ mv ./kubectl /usr/local/bin

2| Cài đặt minikube

# Install
$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.2.0/minikube-linux-amd64
$ chmod +x minikube
$ install minikube /usr/local/bin
$ rm -f minikube

# stop firewall
$ systemctl disable firewalld
$ systemctl stop firewalld

# add addons
$ minikube start --vm-driver=none
$ minikube addons enable heapster
$ minikube addons enable ingress

3| Tạo pod vs image hello-world bằng kubectl trong môi trường minikube

$ kubectl run my-hello-world --image hello-world --restart=Never
pod/my-hello-world create

# [my-hello-world] là tên pod
# [--image hello-world] option --image vs tên image là hello-world
# [--restart=Never] option --restart vs Never: sau khi tạo pod xong sẽ không start

4| Lấy thông tin pod

$ kubectl get pod
NAME            READY   STATUS      RESTARTS    AGE
my-hello-world  0/1     Completed   0           14s

5| Xem thông tin log của pod

$ kubectl logs pod/my-hello-world

6| Xoá pod

$ kubectl delete pod/my-hello-world
pod "my-hello-world" deleted

Leave a Reply

Your email address will not be published. Required fields are marked *