source <(kubectl completion zsh)
alias k=kubectl
compdef __start_kubectl k
k apply -k controllers
# clean up
k delete -k controllers
k apply -k application/wordpress
# clean up
k delete -k application/wordpress
# デプロイメント一覧確認
k get deployments
# サービス一覧確認
k get services
# ポッド一覧確認
k get pods
# まとめて確認
k get all
# シークレット確認
k get secrets
# PersistentVolume 確認
k get pvc
# deploy dashboard
k apply -f monitoring/dashboard.yaml
# create service account
k apply -f monitoring/crerate-service-account.yaml
# getting token
k -n kubernetes-dashboard create token admin-user
# proxy
k proxy
# access
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#!/login
# crean up
k -n kubernetes-dashboard delete serviceaccount admin-user
k -n kubernetes-dashboard delete clusterrolebinding admin-user
k delete -f monitoring/crerate-service-account.yaml
k delete -f monitoring/dashboard.yaml
# debugging pods
k describe pods
# debugging services
k get endpoints
# create a shell
k exec -it nginx-deployment-XXXXXXXXXXXX -- sh
- apiVersion ・・・ 利用する KubernetesAPI のバージョン
- kind ・・・ オブジェクトの種類
- metadata ・・・ オブジェクトを一意に識別するための情報、文字列の name 、 UID 、または任意の namespace
- spec ・・・ オブジェクトの望ましい状態
サンプル
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: LoadBalancer
ports:
- protocol: TCP
port: 8080
targetPort: 80
selector:
app: nginx
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands