Hello Kubernetes

Hello Kubernetes

A hello world guide to play with k8s.

About author

My name is Toby Qin, I am a DevOps engineer working with containerization technology everyday. I had passed my Certified kubernetes Application Developer exam few weeks ago. I create this repo to guide newbies hit their road to cloud.

ckad

Welcome to follow me on github.

Video recording

workshop

针对 Workshop 设计的所有任务,我专门录制了操作视频,欢迎通过以下链接访问获得。

Introducing kubernetes

Setup kubernetes clusters

You have multiple options to setup a kubernetes cluster, I list them down as:

Local setup (not recommended)

It is the hard way of learning, due to the network condition of China, I would not recommend you try this way.

  1. minikube - https://minikube.sigs.k8s.io/docs/start/
  2. kind - https://kind.sigs.k8s.io/
  3. docker desktop - https://www.docker.com/products/docker-desktop
  4. kubeadm - https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/

If you are really want to try the local cluster, I would vote for docker desktop and kind.

Managed k8s clusters

To learn the kubernetes concepts and play with it, using managed k8s cluster is the best choice.

  1. digital ocean - https://m.do.co/c/82dee83362d8
  2. aws - https://aws.amazon.com/cn/kubernetes/
  3. kode kloud - https://kodekloud.com/purchase?product_id=1521964
  4. tencent tke - https://console.cloud.tencent.com/tke2/

I would recommend digital ocean and tecent tke when you picked a managed k8s cluster, because they will give you coupon to try anything for free at the very beginning.

Each platform will have good document or quick guide to help you setup the cluster, please refer to docs there.

Connect to your k8s cluster

Usually we will connect to a k8s cluster by kubectl, see more:

Bookmark the cheatsheet, it is super helpful.

Now edit ~/.kube/config with your cluster info, for example:

apiVersion: v1
clusters:
  - cluster:
      certificate-authority-data: LS0tLS1C...
      server: https://kubernetes.docker.internal:6443
    name: docker-desktop
contexts:
  - context:
      cluster: docker-desktop
      user: docker-desktop
    name: docker-desktop
current-context: docker-desktop
kind: Config
preferences: {}
users:
  - name: docker-desktop
    user:
      client-certificate-data: LS0tLS1CRUdJT...
      client-key-data: LS0tLS1CRUdJTi...

Tips: speed up kubectl command

# add bellow config to ~/.bashrc
source <(kubectl completion bash)
alias k=kubectl
complete -F __start_kubectl k

Enjoy your k8s journey

It is time to play with k8s, I had designed some steps to let you hand on k8s in /steps folder, feel free to explore them :-)

If you want to learn more, I would recommend you go to the official document site to finish the tasks:

You may try more tasks at https://kubernetes.io/docs/tasks/

Tasks designed by me

Happy coding!