LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub

Kubernetes

This is the tutorial that documents the process to install Kubernetes 1.9.3 on four Ubuntu Linux VMs.

Install Master

A new VM will be created, called sandbox, with 2 CPUs, 4GB memory and 30GB hard drive. This server is installed in the Ubuntu 16.04 LTS server. This server will act as a master only and no pods will be deployed on this VM.

The first step will install docker and you can refer to

https://medium.com/@Grigorkh/how-to-install-docker-on-ubuntu-16-04-3f509070d29c

Once docker is installed, we need to install Kubernetes repo

sudo apt-get update
sudo apt-get install -y apt-transport-https
sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

Next let’s create a kubernetes.list file

sudo vi /etc/apt/sources.list.d/kubernetes.list

Add one line as below and save it.

deb http://apt.kubernetes.io/ kubernetes-xenial main

Now let’s install Kubernetes

sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubernetes-cni

With all the packages installed, we need to initialize kubeadm, but first you need to disable swap.

sudo swapoff -a

To make permanent changes you need to comment out the swap file in /etc/fstab file

Before init kubeadms we need to find the ip address of your master server, which can be found through ifconfig

ifconfig

Once you find your network ip address you will use it to replace 10.133.15.28 in the following command line.

sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=10.133.15.28 --kubernetes-version stable-1.9

After the command is completed, it will show you a command to join other nodes to the master.

Something like the following.

sudo kubeadm join --token 582493.ce5e13aa64d9ccb8 10.133.15.28:6443 --discovery-token-ca-cert-hash sha256:fab46528c4a2e0d38bdf60c6ed5042a60a8535ac48443356c06d3f461204af6d

Config a user account or just use the current user if you have logged in with a non-root user.

The following is an example if you are using root so far and you want to create a new user called packet.

sudo useradd packet -G sudo -m -s /bin/bash
passwd packet

Switch to the new user with sudo su packet if you have created a new user packet. Otherwise, stay in the current user session.

$ cd $HOME
$ sudo whoami
$ sudo cp /etc/kubernetes/admin.conf $HOME/
$ sudo chown $(id -u):$(id -g) $HOME/admin.conf
$ export KUBECONFIG=$HOME/admin.conf
$ echo "export KUBECONFIG=$HOME/admin.conf" | tee -a ~/.bashrc

Apply pod network(flannel)

sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml

sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/k8s-manifests/kube-flannel-rbac.yml

Use the following command to ensure that all services are up and running on master.

kubectl get all --namespace=kube-system

Install Worker

After master is installed and all services are running, you can install workers. Here we are going to install three works: test1, test2 and test3.

Make sure that all packages are up to date.

sudo apt-get update
sudo apt-get upgrade

Make sure that docker is installed already.

sudo apt-get install -y apt-transport-https

Install key.

sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

Create kubernetes.list.

echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list

If above command doesn’t work, create the file manually with sudo vi

Once it is done, we need to install Kubernetes.

sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubernetes-cni

Turn off swap by comment out the swap file system

sudo vi /etc/fstab

Turn off the current session.

sudo swapoff -a

Now join the cluster with the command given by the master.

sudo kubeadm join --token 582493.ce5e13aa64d9ccb8 10.133.15.28:6443 --discovery-token-ca-cert-hash sha256:fab46528c4a2e0d38bdf60c6ed5042a60a8535ac48443356c06d3f461204af6d

To ensure that the cluster is up and running, go to master

kubectl get nodes

And you should have something like below.

packet@sandbox:~$ kubectl get nodes
NAME                 STATUS    ROLES     AGE       VERSION
sandbox              Ready     master    1h        v1.9.3
test1                Ready     <none>    19m       v1.9.3
test2                Ready     <none>    1m        v1.9.3
test3                Ready     <none>    49m       v1.9.3

Uninstall

https://medium.com/@meysam1369/kubernetes-completely-uninstall-3f2a83dd985d

references

https://blog.alexellis.io/kubernetes-in-10-minutes/ https://medium.com/@Grigorkh/install-kubernetes-on-ubuntu-1ac2ef522a36

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Kubernetes” was last updated: July 5, 2021: fixes #275 checked and corrected grammar/spelling for majority of pages (#276) (b3bbb7b)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute