DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • A Comparison of Current Kubernetes Distributions
  • Kubernetes Rolling Updates Are Lying to You — and Your Users Are Paying for It
  • Java 27 Makes G1 the Default Everywhere: How to Test Your Small Containers Before You Upgrade
  • A Non-Expiring AKS Deployment Token Could Read Secrets Across Three Namespaces

Trending

  • Running an OpenStreetMap Tile Server for the Whole Planet on Modest Hardware
  • Persisting Cookies Across JAX-WS Service Calls Using a Custom SOAP Handler
  • The "Just Read the Code" Myth Is Killing Your AI Workflow
  • Going All In On the JVM 25 Virtual Threads

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Kubernetes Multi-Node On-Premise Installation With k0s Distribution

Kubernetes Multi-Node On-Premise Installation With k0s Distribution

Explore this written and video tutorial to learn more about Kubernetes multi-node on-premise installation with k0s distribution.

By 
Ramakrishnan E.P.
·
Sep. 27, 21 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
5.4K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

This post is part of the Kubernetes series.

Today I am going to install Kubernetes on-premise. In order to do this, I need some VM’s to simulate multiple nodes.

There are options to create VM such as VirtualBox and Vagrant, but I used Multipass. It is a tool from canonical (Ubuntu Parent company) to create Ubuntu-based VM easily.  It uses multiple backends like LXD, VirtualBox, and KVM.

Cloud-init is a tool that integrates nicely with Multipass.  Cloud-init is a software package that automates the initialization of cloud instances during system boot.

Step 1: 

Create cloud-init.yaml. Include ssh public key and what package you want to install when VM is booted up. We can automate this using cloud-init:

YAML
 
ssh_authorized_keys:

  - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCwj/GIk1hUKTDYzylerSCfXbYnkYZ5Im80pNvzIF8C0fZ/fhu8dgHckyuhc+Jkn4ty9SDqgB9paGhuc4EuITvxQpmHMqsxOm8kqShJB43h7YOb2ZXo/vgUyL8zYlIXch1OKN9j6jkHBtYrEAS96Ojz5x4G0FQLHulJmECz8XOOgyzi9CFx3ElOGZ1oF4M4CcEp5KWLI4zjNhvWyObMON5KLmB7Pwl37zQissOJe/Ic69tdNGaWY3NOY+33IrEowD7KN6JW10x/opZJrOd4FErDh/6PRw5kEXDTF15inOxFhZI5hkneZLnmGJDmQp47m7wmCJeB+NDWD6bWVXc9HP+7 ramki@ramki

packages:

  - open-iscsi

  - nfs-common

Step 2: 

Using Multipass create 5 VM’s. Each VM has 15 CPUs, 20G RAM, 100G HDD.  We specify the cloud-init.yaml file. For post-VM boot up, install the custom tools (here install open-iscsi, nfs-common using apt install).

Shell
 
multipass launch -c 15 -m 20G -d 100G -n master --cloud-init cloud-init.yaml

multipass launch -c 15 -m 20G -d 100G -n worker1 --cloud-init cloud-init.yaml

multipass launch -c 15 -m 20G -d 100G -n worker2 --cloud-init cloud-init.yaml

multipass launch -c 15 -m 20G -d 100G -n worker3 --cloud-init cloud-init.yaml

multipass launch -c 15 -m 20G -d 100G -n worker4 --cloud-init cloud-init.yaml

Step 3: 

Check VM ip address using multipass ls command.

Check VM ip address using multipass ls command

Step 4:

Create a Cluster config file using the following command.

k0sctl init --k0s > k0sctl.yaml

Update the IP address accordingly based on VM’s IP address.

YAML
 
apiVersion: k0sctl.k0sproject.io/v1beta1
kind: Cluster
metadata:
  name: bio-kubernetes

spec:
  hosts:
  - ssh:
      address: 192.168.122.58
      user: ubuntu
      port: 22
      keyPath: /home/htvam/.ssh/id_rsa
    role: controller

  - ssh:
      address: 192.168.122.221
      user: ubuntu
      port: 22
      keyPath: /home/htvam/.ssh/id_rsa
    role: worker

  - ssh:
      address: 192.168.122.92
      user: ubuntu
      port: 22
      keyPath: /home/htvam/.ssh/id_rsa
    role: worker

  - ssh:
      address: 192.168.122.177
      user: ubuntu
      port: 22
      keyPath: /home/htvam/.ssh/id_rsa
    role: worker

  - ssh:
      address: 192.168.122.11
      user: ubuntu
      port: 22
      keyPath: /home/htvam/.ssh/id_rsa
    role: worker

  k0s:
    version: 1.21.3+k0s.0
    config:
      apiVersion: k0s.k0sproject.io/v1beta1
      kind: Cluster
      metadata:
        name: k0s

      spec:
        api:
          k0sApiPort: 9443
          port: 6443
          sans:
          - 192.168.122.125
        images:
          calico:
            cni:
              image: docker.io/calico/cni
              version: v3.18.1
            kubecontrollers:
              image: docker.io/calico/kube-controllers
              version: v3.18.1
            node:
              image: docker.io/calico/node
              version: v3.18.1
          coredns:
            image: docker.io/coredns/coredns
            version: 1.7.0
          default_pull_policy: IfNotPresent
          konnectivity:
            image: us.gcr.io/k8s-artifacts-prod/kas-network-proxy/proxy-agent
            version: v0.0.16
          kubeproxy:
            image: k8s.gcr.io/kube-proxy
            version: v1.21.1
          kuberouter:
            cni:
              image: docker.io/cloudnativelabs/kube-router
              version: v1.2.1
            cniInstaller:
              image: quay.io/k0sproject/cni-node
              version: 0.1.0
          metricsserver:
            image: gcr.io/k8s-staging-metrics-server/metrics-server
            version: v0.3.7
        installConfig:
          users:
            etcdUser: etcd
            kineUser: kube-apiserver
            konnectivityUser: konnectivity-server
            kubeAPIserverUser: kube-apiserver
            kubeSchedulerUser: kube-scheduler
        konnectivity:
          adminPort: 8133
          agentPort: 8132
        network:
          kuberouter:
            autoMTU: true
          podCIDR: 10.244.0.0/16
          provider: kuberouter
          serviceCIDR: 10.96.0.0/12
        podSecurityPolicy:
          defaultPolicy: 00-k0s-privileged
        storage:
          type: etcd
        telemetry:
          enabled: true

Step 5: 

Install Kubernetes using k0sctl command.

k0sctl apply --config k0sctl.yaml

Kubernetes is installed!

Setup the Kube Config file:

k0sctl kubeconfig --config k0sctl.yaml > ~/.kube/config

Video Tutorial:


Kubernetes Distribution (differential geometry)

Published at DZone with permission of Ramakrishnan E.P.. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • A Comparison of Current Kubernetes Distributions
  • Kubernetes Rolling Updates Are Lying to You — and Your Users Are Paying for It
  • Java 27 Makes G1 the Default Everywhere: How to Test Your Small Containers Before You Upgrade
  • A Non-Expiring AKS Deployment Token Could Read Secrets Across Three Namespaces

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook