Skip to content

Latest commit

 

History

History
60 lines (40 loc) · 3.83 KB

kubernetes.md

File metadata and controls

60 lines (40 loc) · 3.83 KB

Using Kubernetes

Read the following if you want to use Kubernetes from your local development environment.

Setup kubectl

You'll need to install and configure kubectl CLI tool to interact with Kubernetes. There are instructions on kubectl configuration in the Cloud Platform User Guide.

Kubernetes namespaces

fala has two namespaces (environments):

Admin role

When you become a member of the GitHub team laa-get-access, you'll automatically get the ClusterRole - admin role.

What is the ClusterRole -admin Allows admin access, intended to be granted within a namespace using a RoleBinding. If used in a RoleBinding, allows read/write access to most resources in a namespace, including the ability to create roles and rolebindings within the namespace. It does not allow write access to resource quota or to the namespace itself. https://kubernetes.io/docs/reference/access-authn-authz/rbac/#default-roles-and-role-bindings

You can find out more about roles in the Cloud Platform User Guide.

Authenticating with the Docker registry

Docker images are stored in AWS ECR. To authenticate with the cla_public repository, fetch the credentials by typing the following:

kubectl --namespace laa-fala-staging get secrets -o yaml

This command will return the encoded AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. You can find out more by reading Authenticating with the repository.

Deploying to Kubernetes

The standard way of deploying is via CircleCI deploy jobs. See Deploy to Kubernetes using CircleCI.

If you need to deploy manually because, for example, CircleCI is offline, follow these steps:

  1. Build the Docker image locally. For example:

    docker build -t fala:latest .
    
  2. Tag the build. For example:

    docker tag fala:latest 926803513772.dkr.ecr.eu-west-1.amazonaws.com/laa-get-access/laa-fala:awesometag
    
  3. Push the docker image. For example:

    docker push 926803513772.dkr.ecr.eu-west-1.amazonaws.com/laa-get-access/laa-fala:awesometag
    
  4. Deploy changes to Kubernetes by applying changes to the deployment.yml. This example takes the deployment.yml as input, changes the value of image for the container named app to 926803513772.dkr.ecr.eu-west-1.amazonaws.com/laa-get-access/laa-fala:awesometag, then pipes the updated yaml to the next command. The kubectl apply applies the yaml from stdin:

    kubectl set image --filename="kubernetes_deploy/staging/deployment.yml" --local --output=yaml app="926803513772.dkr.ecr.eu-west-1.amazonaws.com/laa-get-access/laa-fala:awesometag" | kubectl apply --filename=/dev/stdin
    

    A similiar technique is used in deploy_to_kubernetes script. Of course, you could simply update the deployment.yml file directly and apply the changes.

    The .circleci/deploy_to_kubernetes relies on Circle CI environment variables being present, CIRCLE_BRANCH and CIRCLE_SHA1, so using the script from your local environment isn't possible yet. The plan is to remove these dependencies from the deploy script.