見出し画像

CircleCIのスクリプト集(随時更新)

割引あり

準備

eksのkubectlをCircleCIから叩くので、準備として以下の環境変数をCircleCIのプロジェクトセッティングで設定しておく。

・AWS_ACCESS_KEY_ID
・AWS_SECRET_ACCESS_KEY

可能であれば、以下も環境変数にしておく。

・AWS_DEFAULT_REGION(リージョン)
・CLUSTER_NAME(クラスタ名)

kubectlのインストール

1.14.6バージョンを/usr/local/bin/kubectlへインストールしている例
*ただし、もうこれは古い。以下スクリプトではaws-iam-authenticatorをインストールしているが現在のawscliにはeks get-tokenコマンドが含まれているのでaws-iam-authenticatorのインストールは不要となっているようです。

https://docs.aws.amazon.com/eks/latest/userguide/doc-history.html

The aws eks get-token command was added to the AWS CLI so that you no longer need to install the AWS IAM Authenticator for Kubernetes to create client security tokens for cluster API server communication. Upgrade your AWS CLI installation to the latest version to take advantage of this new functionality. For more information, see Installing the AWS command line interface in the AWS Command Line Interface User Guide.

sudo pip3 install awscli
curl -o aws-iam-authenticator https://amazon-eks.s3.us-west-2.amazonaws.com/1.16.8/2020-04-16/bin/linux/amd64/aws-iam-authenticator
chmod +x ./aws-iam-authenticator
sudo mv ./aws-iam-authenticator /usr/local/bin/aws-iam-authenticator
curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl

kubectlコマンド実行

「kubectlのインストール」でインストールしたawscliを使用してupdate-kubeconfigで接続するEKSクラスタを指定する。

ここから先は

1,650字

この記事が気に入ったらサポートをしてみませんか?