1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【k8s / istio / Docker】コマンド備忘録

Last updated at Posted at 2021-07-09

kubectl logsコマンド

kubectl logs test-pod-8888 -n istio-system -f --tail=10

kubectl createコマンド

kubectl create deployment nginx --image=nginx -n istio-system

kubectl rolloutコマンド

kubectl rollout restart deployment/ingressgateway -n istio-system
kubectl rollout history deployment/ingressgateway -n istio-system
kubectl rollout status deployment/ingressgateway -n istio-system
kubectl set image deployment/ingressgateway <Pod名>=<イメージURL> -n istio-system

kubectl taintコマンド

kubectl describe node | grep Taint
kubectl taint nodes <ノード名> key1=value1:NoSchedule-

kubectl all namespacesコマンド

kubectl get pods --all-namespaces -o=jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{range .spec.containers[*]}{.image}{", "}{end}{end}' |\
sort

istioctlコマンド

istioctl proxy-config cluster test-ingressgateway-8888 -n istio-system -o json | grep -20 "test-word"

istioctl installコマンド

istioctl install -f /istio/install.yaml --context <コンテキスト> -y

systemctlコマンド

systemctl list-units --type=service

curlコマンド

curl -vvv https://www.docker.com -x http://test-proxy:8888

疎通確認コマンド

$ sudo yum install nmap
$ nping 12.34.56.789 -p 8888
$ nc -v -z 12.34.56.789 8888
$ echo "" > /dev/tcp/12.34.56.789/8888 && echo "Port open." || echo "Port closed...."
$ timeout 5 bash -c "</dev/tcp/12.34.56.789/8888" && echo "Port open." || "echo Port closed."

AWS CLIコマンド

$ aws s3api head-object --bucket my-s3bucket --key my-s3object
$ aws cloudwatch set-alarm-state --alarm-name my-alarm-test --state-value ALARM --state-reason "test"

調査コマンド

du -sh /*
find ./ -type f -name "test.log*"
cp /dev/null hoge.txt
sudo cat /var/log/messages | grep Failed

ECRコマンド

$ aws ecr get-login --no-include-email --registry-ids 88889999 --region ap-northeast-1

journalctlコマンド

$ journalctl -k
$ journalctl -u nginx | grep -A 20 "test-word"

systemctlコマンド

$ systemctl list-unit-files --type=service

secretsmanagerコマンド

$ aws secretsmanager get-secret-value --secret-id test-key --query 'SecretBinary' --output text --region ap-northeast-1

terraform targetコマンド

$ terraform plan -target module.test_vpc

kubectl rolloutコマンド

$ kubectl rollout history deployment nginx-deployment
$ kubectl set image deployment nginx-deployment nginx=nginx:1.21.1
$ kubectl rollout status deployment nginx-deployment
$ kubectl rollout history deployment nginx-deployment
$ kubectl rollout undo deployment nginx-deployment

pod確認

$ kubectl get pod -A
$ kubectl get pod -w  // ずっと表示
$ kubectl get pod --namespace=istio-system

Envoy-Proxyデバッグ

$ kubectl describe pod <Pod名> -n istio-system  // コンテナ名取得
$ kubectl exec -it <Pod名> -c <コンテナ名> -n istio-system bash

ログ確認

$ kubectl logs <NAME> -n istio-system
$ kubectl describe pod <NAME> -n istio-system

インストール済みAPI確認

$ kubectl get api-versions

YAML表示

$ kubectl get pod <NAME> -n istio-system -o yaml | less

エンドポイント表示

$ kubectl get ep -n istio-system

pod一括削除

kubectl delete --all pods -n istio-system

編集・アンインストール

$ kubectl edit <NAME> deployment -n istio-system
$ kubectl delete namespace istio-system

コンテキスト表示

$ kubectl config get-contexts
$ kubectl config current-context

istioサイドカーインジェクション

$ kubectl label namespace default istio-injection=enabled  // 有効
$ kubectl get namespace -L istio-injection  // 確認
$ kubectl label namespace default istio-injection=disabled --overwrite
$ kubectl label namespace default istio-injection-

ClusterRole / ClusterROleBinding

$ kubectl get ClusterRole -n istio-system
$ kubectl get ClusterRoleBinding -n istio-system

Docker

停止・削除

$ docker stop $(docker ps -q)
$ docker rm -f `docker ps -a -q`
$ docker rmi `docker images -q`

Dockerプロキシ設定

$ sudo mkdir -p /etc/systemd/system/docker.service.d
$ sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf

[Service]
Environment="HTTP_PROXY=http://test-proxy:8888"
Environment="HTTPS_PROXY=http://test-proxy:8888"

$ sudo systemctl daemon-reload
$ sudo systemctl enable docker
$ sudo systemctl restart docker

イメージ作成

$ docker build -f docker/Dockerfile -t image_01 .

ローカルマウント && ポート指定

$ docker run -itd -p 127.0.0.1:8000:8000 -v ~/Developer/sample_app:/var/www/sample_app --name container_01 image_01

terraform

state

$ terraform state list
$ terraform state rm <state名>
$ rm -rf .terraform

MySQL

column表示

$ show columns from sampler_tweetsdata;

削除

$ delete from sample_data where id = 1;

追加

$ insert into sample_data values (1, 200);

Git

ブランチ切り替え失敗時

$ git merge --abort

キャッシュクリア

$ git rm -r --cached .

フェッチ

$ git fetch --all
$ git fetch --tags --all

参考文献

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?