$ kubectl cluster-info Kubernetes control plane is running at https://192.168.49.2:8443 KubeDNS is running at https://192.168.49.2:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debugand diagnose cluster problems, use 'kubectl cluster-info dump'.
kubectl get all: 取得Kubernetes Pods, Deployments, Services等相關資訊
1 2 3
kubectl get all NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 59m
取得pod資訊,可以多加 --watch,持續監測pod狀態
1 2 3
$ k get pods --watch NAME READY STATUS RESTARTS AGE postgres-lastest 0/1 CrashLoopBackOff 69m49s
kubectl run [contanier-name] --image=[image-name] 創建kubernetes服務內容
k create -f postgres.yaml pod/postgres-pod created
kubectl delete [pod, service, deployment..] 砍掉服務
若要砍掉一個pod名稱 postgres-1,
1 2
$ k delete pods postgres-1 pod "postgres-1" deleted
kubectl logs [pods] 查看服務狀態
如果有個服務要檢查其訊息,可透過kubectl logs檢查
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
$ k logs postgres-pod The files belonging to this database system will be owned by user "postgres". This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8". The default database encoding has accordingly been setto"UTF8". The default text search configuration will be setto"english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default timezone ... Etc/UTC
$ k logs postgres-lastest Error: Database is uninitialized and superuser password is not specified. You must specify POSTGRES_PASSWORD toa non-emptyvalueforthe superuser. For example, "-e POSTGRES_PASSWORD=password"on"docker run".
You may also use "POSTGRES_HOST_AUTH_METHOD=trust"to allow all connections withouta password. This is *not* recommended.
See PostgreSQL documentation about "trust": https://www.postgresql.org/docs/current/auth-trust.html