---
# System prepended metadata

title: Kubernetes 指令參考筆記
tags: [k8s]

---

# Kubernetes 指令參考筆記
###### tags: `k8s`

[Day 11 Kubernetes 閃電戰-kubernetes 安裝基礎操作篇](https://ithelp.ithome.com.tw/articles/10244493)

[常見的 kubectl 指令
](https://ithelp.ithome.com.tw/articles/10203675)
 
參考筆記

## 資源部署
### Pod指令
#### Deploy Pod：建立Pod
kubectl apply -f "Pod的yaml檔"
#### Get Pod Status：取得Pod狀態
kubectl get pod -o wide
#### Delete Pod：刪除Pod
kubectl delete pod "Pod 名稱"

### Deployment指令
#### Deploy Deployment：建立Deployment
kubectl apply -f "Pod的yaml檔"
#### Get Deployment Status：取得Deployment狀態
kubectl get deployment -o wide
#### Get Deployment's Replicas Pod Status：
kubectl get pod -o wide
#### Delete Deployment：刪除Deployment
kubectl delete deployment "Deployment 名稱"

### Service指令
#### Create Connection Pod (with Layer 7 Connection)：
kubectl apply -f "Pod的yaml檔"
#### Service Deployment：
kubectl apply -f nginx-clusterip-service.yaml
#### Get Deployment Status (ClusterIP)：
kubectl get service -o wide
#### Testing Service：
curl "前一個指令查到的service IP":3000
#### Internal Domain Testing (on Pod)(在Pod上測試)：
kubectl get endpoints
#### Enter Pod：(進Pod裡面)
kubectl exec --stdin --tty nginx-pod -- /bin/bash
#### Testing Domain：
curl nginx-service-clusterip:3000
Delete Service：
kubectl delete service "Service 名稱"

### NodePort指令
#### Service Deployment：
kubectl apply -f nginx-nodeport-service.yaml
#### Get Deployment Status (NodePort)：
kubectl get service -o wide
#### Testing Service：
"機房主機網址":"指令的port號碼"
