kubectl
基本形式
kubectl [コマンド] [リソースタイプ] [名前] [オプション]
現在のk8sクラスター
kubectl config current-context
-o=yaml
yamlフォーマットで表示
kubectl run hoge --image=busybox --restart=Never --dry-run -o yml
設定ymlを表示してくれる
run実行
kubectl run hello-world --image=hello-world -it --restart=Never
restartでpodのコントロールの方法(特性)を指定しているようなイメージだね
table:restart
Never podが直接起動される
Always Deploymentから起動される
OnFailure Jobから起動される
kubectl run hello-world --image=hello-world -it --restart=Never --rm
rmをつけることでポッドが自動で削除される
hiroki.iconk8s上で一発バッチ処理をどかってやりたい時とかにこれ使えるね
deleteでリソースの削除
kubectl delete pod ポッド名
kubectl delete pod/ポッド名
kubectl delete deploy オブジェクト名
kubectl delete -f ymlファイル
ポッドのログ
kubectl logs ポッド名
k8sのダッシュボード
kubectl proxy
マニュフェストの適用
kubectl apply -f ファイル名
Serviceの作成 expose