Skip to main content

What is kubernetes

K8S Orchestration engine

While using Heroku we was deploying code directly from a repo, to do that we prepared our code with some shell scripts (bash mainly) and then containerized that with heroku-cli, which then deployed containers to Heroku - online platform to host and manage containerized applications. The main idea of a container is to keep data separately from application allowing higher level of abstraction and easier manipulation.

Keeping containerized apps up and running can be complex because they often involve many containers deployed across different machines. Kubernetes engine just provides a way to schedule and deploy those containers—plus scale them to our desired state and manage their lifecycles. We use Kubernetes to implement our container-based Ruby on Rails application in a portable, scalable, and extensible way.

kubernetes scheme

Docker

In GKE setup we use Docker to containerize our app. Kubernetes and Docker work together. Docker provides an open standard for packaging and distributing containerized applications. Using Docker, you can build and run containers, and store and share container images.

Kubernetes orchestrates and manages the distributed, containerized applications that Docker creates. It also provides the infrastructure needed to deploy and run those applications on a cluster of machines. To read more on that follow this guide.

General info on K8s in POWR

To use k8s tools and operate with cloud you will need gcloud cli and kubectl, fortunately both could be easily obtained by brew:

brew install --cask google-cloud-sdk

brew install kubernetes-cli

After successful installation you need to authorize gcloud cli with your google account

gcloud auth login

Now you if your k8s acesses are set you are able to get cluster information and authorize kubectl
depending on which environment you need run one of the following

gcloud container clusters get-credentials alpha --region us-east1 --project powr-staging

gcloud container clusters get-credentials staging --region us-east1 --project powr-staging

gcloud container clusters get-credentials main --region us-east1 --project powr-prod

You could check if access is correct by running any of kubectl commands below

kubectl -n staging get all

kubectl get all -A

Best source of info on GKE and everything on powr listed here

more information on gcloud

more information on kubectl

to enable autocomplete with kubectl and gcloud on OMZ: kubectl plugin

Heroku vs GKE commands cheatsheet

It's here

How to install and setup kubectl?

Follow this guide

How to deploy and use kubectl?

Read more on that here

How to use kubectl?

Follow this guide

How to login to Google Cloud Console

Go to https://console.cloud.google.com/kubernetes/list/overview?project=powr-staging after logging in to your powr account. This page shows active clusters that we use on staging.

How autoscale works on K8S?

Horisontal Pod Autoscaling

How to use GHCR and download last container image?

After installing docker run this command:

docker login ghcr.io

And pass authorization procedure. Then run:

docker run ghcr.io/powrful/<github-branch>/web:latest -it /bin/bash

It will run the same image as on k8s pod but on your local machine

How to use review-apps on github and k8s and why they called prapps?

Read more on that here

How to test if your code will run inside container?

This guide will describe how to run docker images locally and debug their deployments

How schedulers work on GKE?

Check this article