-
Notifications
You must be signed in to change notification settings - Fork 22
Kubectl Setup
Both staging and production services run on our Kubernetes cluster. In order to interact with the cluster or the deployments you will need to configure kubectl locally.
You will need to install kubectl version 1.13 or later on your machine. If you're on macOS the simplest option is brew install kubernetes-cli
. You can check the version with kubectl version --client --short
.
You will need to have the AWS cli installed. You will need to have a profile named rubygems
configured.
You can confirm with aws sts get-caller-identity --profile rubygems
On macOS, the simplest option is probably brew install aws-iam-authenticator
. You can check the install by running aws-iam-authenticator help
.
Amazon also provides install instructions: https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html
NOTE: You need the jq
utility installed for the following steps.
mkdir -p ~/.kube
export RUBYGEMS_CLUSTER_CA=$(aws eks describe-cluster --region us-west-2 --profile rubygems --name rubygems | jq -r '.cluster.certificateAuthority.data')
export RUBYGEMS_CLUSTER_ADDRESS=$(aws eks describe-cluster --region us-west-2 --profile rubygems --name rubygems | jq -r '.cluster.endpoint')
cat >~/.kube/rubygems.config <<EOF
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: ${RUBYGEMS_CLUSTER_CA}
server: ${RUBYGEMS_CLUSTER_ADDRESS}
name: rubygems
contexts:
- context:
cluster: rubygems
user: aws
name: rubygems
kind: Config
preferences: {}
users:
- name: aws
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
args:
- token
- -i
- rubygems
command: aws-iam-authenticator
env:
- name: AWS_PROFILE
value: rubygems
EOF
Then add this to your shell initialization file:
export KUBECONFIG=$KUBECONFIG:~/.kube/rubygems.config
You can confirm everything works:
kubectl get deploy -n rubygems-staging --context rubygems
If you need more help, you can reference the full AWS instructions.