How to create a Kubernetes Cluster via Kubeadm?

Search for a command to run...

No comments yet. Be the first to comment.
There are ways to connect two Virtual Networks in Azure: VPN Gateway VNET Peering, with a click of a button. Regional Peering Global Peering VNET space must be non overlapping VNET peering is completely private. VPC peering has no cost for al...
Goal for this Article: Create an RBAC for a team member that have access to a specific namespace. OPENSSL: Creating Key, CSR, Certificate Signing Request, Using CA.key and CA.crt to create a CRT for the user Create a key and a CSR from the created...
The four tenets of DevOps - Operations: GitOps: A software development methodology that emphasizes using Git as a single source of truth for managing infrastructure and application deployments. SRE: A set of practices that blends software engineeri...

High Level Plan The architecture will begin with the use of the MS Graph Security API to fetch alerts from MS 365 Defender. This will be triggered using an Azure Function, which will then store the response in a CSV file. The CSV file will be loaded ...

Installing Spinnaker in a Kubernetes cluster is very straightforward. Here are the things we will do: Install Spinnaker Operator Install Spinnaker Modify spinnakerservice. (Add overridebaseUrl & GitHub Oath) Exposing spinnaker via Ingress Insta...

Topics Covered:
The Kubernetes Cluster Architecture
Building our Kubernetes Cluster
Kubeadm Installation and Deep Dive
Understanding Kubernetes Static Pods
Understanding CNI
Working with Kubectl context and kubeconfig
Working with Role Base Accessed Control
Maintaining the Cluster
Managing the certs and rotation
Upgrading the Cluster
Backing up the etcd

Control Plane
API Server - handles the request from client such as kubectl. Responsible for authentication and authorization of request.
Etcd - stores the state of the cluster and its configurations
Scheduler - schedule a pod to a node.
Controller - runs an infinite loop to maintain the desired state to the current state (e.g. cronjobs, daemonsets, replicasets)
Worker Plane
Kubelet - receives instruction from the scheduler then assigns the Pods to a Container Runtime
Container Runtime - allows a pod/containers to be runnable. Eg. docker, cri-o
Kubeproxy - forward the request to the appropriate service and endpoints.
https://devopscube.com/setup-kubernetes-cluster-kubeadm/
Good to know:


These are the pods that are created when boostrapping a cluster via kubeadm on the kube-system :
coredns - default dns for kubernetes. Provides service discovery and resolving dns names. DNS allows us to map a name to an IP. Allows use of external domain name.
kube-proxy - forward the request for appropriate endpoints and services. acts as a proxy, intercepts a traffic and redirect to specific service.
etcd - store the state of the cluster. Responsible for persisting configuration. (Stores endpoint)
apiserver - handles incoming requests from kubectl and others. Responsible for aut
scheduler - schedules pods to worker nodes
controller - runs an infinite loop to maintain the desired state to the current state (e.g. cronjobs, daemonsets, replicasets)
There are two main purpose of Kubernetes Networking plugin:
Makes sure the cluster have L3 Connectivity. (Routing traffic to different environments [both at pods and node levels] )
Network Policy enforcement
IPAM
A Kubernetes context consists of a cluster, a namespace, and a user and is the configuration used to access a specific cluster and namespace
Allows use to give access to specific user
Steps:
adduser team-readonly
passwd team-readonly
openssl genrsa -out team-readonly.key 2048
openssl req -new -key team-readonly.key \
-out team-readonly.csr -subj "/CN=team-readonly"
sudo openssl x509 -req -in team-readonly.csr \
-CA /etc/kubernetes/pki/ca.crt \
-CAkey /etc/kubernetes/pki/ca.key \
-CAcreateserial \
-out team-readonly.crt -days 360
team-readonly user
kubectl config set-credentials team-readonly \
--client-certificate=team-readonly.crt \
--client-key=team-readonly.key
kubectl config set-context nontechnical-view \
--cluster=kubernetes \
--namespace=databases \
--user=team-readonly
5. Add RBAC to the user
Create role / cluster role
Create rolebinding / cluster rolebinding
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: databases # Same namespace as the one in the context
name: team-readonly
rules:
- apiGroups: ["", "extensions", "apps"]
resources: ["deployments", "replicasets", "pods", "nodes"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: team-readonly-role-binding
namespace: databases
subjects:
- kind: User # Here we say it's a normal user and not a service account
name: team-readonly # Here is where we define the user we created and defined in the context
apiGroup: ""
roleRef:
kind: Role
name: team-readonly
apiGroup: ""
Check this: https://kubernetes.io/docs/reference/access-authn-authz/rbac/
Different users/groups == different level access. (cluster level, namespace level, resources, verbs access, particular application, api groups etc)
Roles and Cluster roles containes (resources, verbs) that is rolebinded (rolebinding) to users/groups/service accounts.
Elements:
Cluster role / role
Cluster rolebinding / rolebinding
Users Groups and Service Accounts
Managing the certs and rotation
Upgrading the Cluster
Backing up the etcd
Those maintenance tasks above have different implementations, you can use a configuration management tool to automate the process.