Main Page

From kube.wiki
The original idea of a container has been around since the 1970s, when the concept was first employed on Unix systems to better isolate application code.

Welcome to kube.wiki

An initiative by Henric Romlin (2019-02-05) - hello@kube.wiki

Kubernetes (k8s) is an open-source system for automating deployment, scaling, and management of containerized applications. It groups containers that make up an application into logical units for easy management and discovery. Kubernetes builds upon 15 years of experience of running production workloads at Google, combined with best-of-breed ideas and practices from the community. (https://kubernetes.io 2019-02-05)

Prerequisites

Terraform
https://learn.hashicorp.com/terraform/getting-started/install.html

Infrastructure as code (IaC) is the process of managing and provisioning computer data centers through machine-readable definition files, rather than physical hardware configuration or interactive configuration tools. (https://en.wikipedia.org/wiki/Infrastructure_as_code 2019-02-05)

Setup IaC on Google Cloud Platform using Terraform

terraform-gke (credit to Fredrik Lack - https://fre.la)
https://github.com/kube-wiki/terraform-gke

Create a new Kubernetes cluster bootstrapped with Helm (https://helm.sh/), NGINX Ingress Controller (https://github.com/kubernetes/ingress-nginx) and cert-manager (https://docs.cert-manager.io/en/latest/)

Workloads on GCP
  1. Kubernetes Enginge API requires a billing account on GCP, but please be careful as charges may be expensive - https://cloud.google.com/billing/docs/how-to/manage-billing-account
  2. Enable Kubernetes Engine API and Compute Engine API
  3. Install Docker Desktop on your local machine - https://www.docker.com/products/docker-desktop
  4. Install Terraform on your local machine - https://learn.hashicorp.com/terraform/getting-started/install.html
  5. Clone https://github.com/kube-wiki/terraform-gke to your local machine
  6. Create a new Cloud Storage bucket for Terraform to store the state remotely, e.g. kube-wiki-tf-state (read more about remote state at https://www.terraform.io/docs/state/remote.html)
  7. Edit backend.tf (remote state) and variables.tf
  8. Open Terminal and navigate to /terraform-gke
  9. Initialize a Terraform configuration with the command terraform init
  10. The command terraform apply is used to apply the changes required to reach the desired state of the configuration

The terraform destroy command is used to destroy the Terraform-managed infrastructure (https://www.terraform.io/docs/commands/destroy.html)

https://cloud.google.com/kubernetes-engine/release-notes

Useful commands

  • kubectl config unset contexts

Deploy WordPress to a Kubernetes cluster

Open source WordPress is the most popular online publishing platform, currently powering more than 32% of the web (https://wordpress.com/about/ 2019-02-06). Now we will deploy WordPress to a Kubernetes cluster, using the modern and composer based boilerplate Bedrock (https://roots.io/bedrock/).

https://github.com/kube-wiki/wordpress-gke (credit to Fredrik Lack - https://fre.la & Andreas Ek - https://elseif.se)

  1. Install Docker Desktop on your local machine - https://www.docker.com/products/docker-desktop
  2. Clone https://github.com/kube-wiki/wordpress-gke to your local machine
  3. Open Terminal and navigate to /wordpress-gke
  4. Run composer self-update (if needed)
  5. Run composer install
  6. Add 127.0.0.1 localunixsocket and 127.0.0.1 local.kube.wiki to /etc/hosts
  7. Start up WordPress by running docker-compose up
  8. Go to local.kube.wiki in a browser of your choice

Useful Docker CLI commands
docker system prune - Remove unused data
docker ps - List containers

Useful Docker kubectl commands
kubectl config current-context - Display the current-context
kubectl config use-context my-cluster-name - Set the default context to my-cluster-name
kubectl get pods - See all Pods running in your cluster