- Setting up Kubernetes clusters
- Local cluster using Kubespray and Vagrant
- Change base OS
- Fixing connectivity issues with
kube proxy
andVagrant
- Starting the cluster
- Administration
- Deploy and run a sample voting app
- Persistent storage
- Installing and configuring the
Helm
package manager - Using
Terraform
to manage resources on your cluster - Using
kompose
to translateDocker Compose
files toKubernetes
- Using
Kubeless
to support serverless functions on your cluster
- Local cluster using Kubespray and Vagrant
Refer to https://github.com/kubernetes-incubator/kubespray/ for more information.
$ git clone https://github.com/kubernetes-incubator/kubespray.git
$ cd kubespray
Change your base OS to CentOS.
$ echo "\$os = \"centos\"" >> vagrant/config.rb
You will have issues with connecting to cluster services using kube proxy across multiple hosts.
You need to update the flannel
configuration such that networking combined with Vagrant
works properly.
Modify kubespray/inventory/sample/group_vars/k8s-cluster.yml
and add the following variable.
flannel_interface: eth1
$ vagrant up
Also refer to https://kubernetes.io/docs/reference/kubectl/cheatsheet/ for more information.
Getting cluster information.
vagrant@k8s-01:~$ kubectl cluster-info
Kubernetes master is running at http://localhost:8080
KubeDNS is running at http://localhost:8080/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
kubernetes-dashboard is running at http://localhost:8080/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Forwarding port 8001 on the host to 8001 on the guest
$ echo '$forwarded_ports = {8001 => 8001}' >> vagrant/config.rb
$ vagrant reload
$ vagrant provision
Setting up a proxy to the cluster on port 8001
$ vagrant ssh k8s-01
vagrant@k8s-01:~$ kubectl proxy --port=8001 --api-prefix=/ --address='0.0.0.0'
Give the dashboard admin access for development purposes.
Also refer to https://github.com/kubernetes/dashboard/wiki/Access-control for more information.
You can grant full admin privileges to Dashboard's Service Account by creating below ClusterRoleBinding
. Copy the YAML file based on chosen installation method and save as, i.e. dashboard-admin.yaml. Use kubectl create -f dashboard-admin.yaml
to deploy it. Afterwards you can use Skip option on login page to access Dashboard.
Browse to the dashboard at http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/login and click on "Skip"
Note: don't use this configuration for production clusters because of the security risks!
Please refer to sample-app.md for installing a sample voting app on your cluster.
A StorageClass
provides a way for administrators to describe the “classes” of storage they offer. Different classes might map to quality-of-service levels, or to backup policies, or to arbitrary policies determined by the cluster administrators. Kubernetes itself is unopinionated about what classes represent. This concept is sometimes called “profiles” in other storage systems.
Also refer to https://kubernetes.io/docs/concepts/storage/storage-classes/
You can define a storage class for local storage by creating below StorageClass
. Copy the YAML file based on chosen installation method and save as, i.e. local-sc.yaml. Use kubectl create -f local-sc.yaml
to deploy it.
You can allocate some space for persistent storage by creating below PersistentVolume
. Copy the YAML file based on chosen installation method and save as, i.e. local-pv.yaml. Use kubectl create -f local-pv.yaml
to deploy it.
Note: don't use this configuration for production clusters!
Also refer to https://kubernetes.io/docs/concepts/storage/persistent-volumes/
You can claim some space for persistent storage by creating below PersistentVolumeClaim
. Copy the YAML file based on chosen installation method and save as, i.e. local-pvc.yaml. Use kubectl create -f local-pvc.yaml
to deploy it.
Helm helps you manage Kubernetes applications — Helm Charts helps you define, install, and upgrade even the most complex Kubernetes application.
Charts are easy to create, version, share, and publish — so start using Helm and stop the copy-and-paste madness.
The latest version of Helm is maintained by the CNCF
- in collaboration with Microsoft
, Google
, Bitnami
and the Helm contributor community
.
Also refer to https://docs.helm.sh/ for documentation.
In this case we'll installing Helm on one of the nodes. However, you're also able to install it on your host machine.
Please refer to helm.md for installing and configuring Helm
While you could use kubectl
or similar CLI-based tools mapped to API calls to manage all Kubernetes resources described in YAML files, orchestration with Terraform presents a few benefits.
Please refer to https://www.terraform.io/docs/providers/kubernetes/guides/getting-started.html for more information.
Please refer to terraform.md for managing resources using Terraform
.
kompose
is a tool to help users who are familiar with docker-compose
move to Kubernetes. kompose
takes a Docker Compose file and translates it into Kubernetes resources.
kompose
is a convenience tool to go from local Docker development to managing your application with Kubernetes. Transformation of the Docker Compose format to Kubernetes resources manifest may not be exact, but it helps tremendously when first deploying an application on Kubernetes.
Please refer to kompose.md for translating Docker Compose
to Kubernetes
.
Kubeless is a Kubernetes-native serverless framework that lets you deploy small bits of code (functions) without having to worry about the underlying infrastructure. It is designed to be deployed on top of a Kubernetes cluster and take advantage of all the great Kubernetes primitives.
Please refer to https://kubeless.io/ for more info.
Refer to kubeless.md for installing Kubeless
and deploying sample serverless functions on your cluster.