Getting Started With Kubernetes In 2 Days

Check out these tools to help you deploy and manage your K8s clusters from the ground up...

Kubernetes (commonly abbreviated as K8s) is an open-source platform for container orchestration that we use extensively at ZippyOPS. It automates many of the tasks involved in maintaining a container-based app, such as deploying, scaling, load-balancing, and auto-scaling.

Kubernetes Done Wrong

Kubernetes is a major asset for modern container management and has streamlined deployment for thousands of companies. However, it is infamous for its steep learning curve. Simply put, Kubernetes is difficult to get right.

That being said, if you’re a developer trying to learn and navigate the Kubernetes iceberg, you’re in luck; there are an abundance of open-source resources to help start your K8s journey on the right foot.

Kubernetes Done Right

Although it may be tempting to take shortcuts when working with K8s, keep in mind that proper K8s will:

  • reduce your cloud costs by scaling your clusters efficiently
  • simplify the different engineering processes for your team (eg. development, testing, and releasing)
  • minimize security issues, such as cross-container communication
  • shape how traffic moves through infrastructure
  • prevent resource-hungry services from disrupting each other

Your Kubernetes Journey

While it is true that learning Kubernetes is a long, involved process, it’s also true that everyone has to start somewhere. In just 2-3 days, you can deploy and manage containers with Kubernetes, either locally or in the cloud. This will be a high-level guide, but we’ll provide plenty of links that delve deeper into these topics.

Before We Begin..

You’ll want to download and install kubectl, the main command used to interact with your cluster.

Day 0: Local Cluster

Setting up a local K8s cluster is a good way to get comfortable with basic operations and concepts.

Minikube

If you want to start from ground zero, minikube is a great option. With minikube, you can quickly and easily set up a local K8s cluster through the command line. Here’s an interactive tutorial on creating your first cluster with minikube from the K8s documentation.

K3d

k3d is rapidly gaining momentum as a way of locally running k3s (a lightweight version of K8s). One of k3d’s most enticing features is that it allows you to create and manage your clusters in Docker (as opposed to through minikube, which runs in a virtual machine). Check out this starter repo for a sample k3d app.

Here’s a sample manifest for an nginx deployment:

YAML

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

Helm
Once you want to deploy multiple copies of an application, maintaining several slightly different copies of a manifest can be difficult.
This is where templating comes in. Using a templating tool, you can easily create and manage variations of an application, keeping certain values universal and changing others as needed. Helm is a comprehensive tool for cluster creation and release management.

Helm has also become the defacto K8s system for packaging whole applications. These bundles are called charts. For example, you can use charts to install monitoring services (metric collectors, a time series database, and dashboards) using helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack.


Day 2: Managing
Now you have a cluster deployed, but you want to know what’s going on.
Kubectl
The classic command-line tool kubectl is useful for overseeing your K8s clusters. You can get the state of any objects K8s is aware of, view live logs, and get a shell in your pods. A few useful, lesser known goodies are:
• kubectl watch - see live events for your K8s objects
• kubectl port-forward - ad-hoc port tunneling from localhost to a service in the cluster
• kubectl proxy - create local proxy to kubernetes API
Stern

If you want to quickly log sets of pods at a time, kubectl won’t really help there. For that, we have stern.
Using stern, you can view logs across any specified (via regex) set of pods. It even shows logs for services that start and stop during execution.
For example, running stern -n kube-system dns will show all the logs for any pods in the kube-system namespace that contain the string “dns”.

K9s And Lens
As far as overview tools go, k9s and Lens are two sides of the same coin. Whichever one you choose really boils down to personal preference — both are full-featured and well-maintained.

K9s
If you like a terminal-based console, k9s is the essential dashboard for monitoring your existing K8s clusters. k9s hosts a selection of useful features, such as benchmarking and resource-allotment info.

Lens

If you prefer usability and clarity provided by a GUI, check out Lens. It provides an assortment of tools for general cluster overview, as well as others that allow you to dive into detailed configurations with a few clicks.

Congratulations!

With the help of the tools listed, you’ll be well on your way to Kubernetes enlightenment.

If you’re looking to learn more, keep in mind that Kubernetes has a dedicated community of devs and users who are putting out new and informative docs, services, and tutorials every single day!

Thanks for reading, and good luck on your journey.


We ZippyOPS, Provide consulting, implementation, and management services on DevOps, DevSecOps, Cloud, Automated Ops, Microservices, Infrastructure, and Security

Services offered by us: https://www.zippyops.com/services

Our Products: https://www.zippyops.com/products

Our Solutions: https://www.zippyops.com/solutions

For Demo, videos check out YouTube Playlist: https://www.youtube.com/watch?v=4FYvPooN_Tg&list=PLCJ3JpanNyCfXlHahZhYgJH9-rV6ouPro


Relevant Blogs:

How to Explain Kubernetes to a Business Team 

Hardening Your Kubernetes Cluster: Threat Model 

Multi-Container Pod Design Patterns in Kubernetes 

Kubernetes Logging in Production


Recent Comments

No comments

Leave a Comment