Skip to main content

Posts

Showing posts with the label Cluster

Create a Kubernetes cluster using kind (Kubernetes in Docker) in less than 2 minutes

Why Sometimes I just need to quickly test a K8s resource or compare a cluster with a near vanilla version. This is where kind comes in handy, as it can create a clean and fresh Kubernetes cluster in under 2 minutes. Requirements You have a working docker environment. Step 1 Download the kind binary (less than 4 MB). curl -Lso ./kind https://kind.sigs.k8s.io/dl/v0.11.0/kind-linux-amd64 && chmod 755 kind Step 2 Create the actual cluster. $ time ./kind create cluster Creating cluster "kind" ...  ✓ Ensuring node image (kindest/node:v1.21.1)  ✓ Preparing nodes  ✓ Writing configuration  ✓ Starting control-plane  ✓ Installing CNI  ✓ Installing StorageClass Set kubectl context to "kind-kind" You can now use your cluster with: kubectl cluster-info --context kind-kind Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community real     1m55.934s user    0m1.014s sys     0m0.970s Step 3 That's it really - just use  kubectl   (ideally

Building Kubernetes Clusters using Kubespray

Disclaimer I have published this post on my work blog https://reece.tech previously. Preface We are hosting our workloads in Docker containers within various Kubernetes clusters. To ensure consistency and repeatability across environments, we are using idempotent configuration management tools like Ansible. Kubespray is an Ansible playbook used to manage Kubernetes clusters including initial build and also lifecyle of the cluster (adding or removing nodes, version upgrades etc.). Requirements We are automatically provisioning new VMs in our VSphere environment using Ansible. Once the new node is up and running, Kubespray runs across to install required Kubernetes services. In this example we are using a root user ssh key for passwordless authentication. Ansible 2.5 Kubespray git repository Steps Getting Kubespray The following commands will download Kubespray, select the latest release version and install necessary Python modules. git clone https://github.com/kubernetes-sigs/kubespray

Quick and simple parallel ssh command shell script

Why Sometimes running commands across a range of servers is necessary. Yes, there is Ansible, Puppet and SaltStack etc., however in some cases this is overkill (and these usually require python, ruby or other languages installed. The following shell script runs commands (via sudo if required) on a group of hosts in parallel. It is quite old and not very elegant but does the trick and hopefully helps somebody in the future. Please don't comment on syntax and bugs. Configuration The .run file in your home directory contains one line for user: and one line for pass: . Should this file not exist, the script will ask for the user and password interactively. The servers file includes one line per host (or includes for additional host files) - or if the file does not exist it will be treated as single host name. Usage ./run.sh server "uptime" Script #!/bin/bash # # About: Script to concurrently run commands on a list of servers (with or without sudo) # Author: Lonestarr # Las