Skip to content
This repository has been archived by the owner on Jul 11, 2020. It is now read-only.

Kubectl Setup

André Arko edited this page Feb 24, 2019 · 5 revisions

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.

1. Install kubectl

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.

2. Ensure AWS cli is configured

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

3. Install aws-iam-authenticator

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

4. Setup kubeconfig

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

5. Test

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.