Skip to content
/ k3d-demo Public

Local developemt setup for a Kubernetes cluster

Notifications You must be signed in to change notification settings

akikr/k3d-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

K3d Setup

Refer: k3d.io a wrapper of K3s(Lightweight Kubernetes: k3s.io) in docker

Install K3d via k3d-installers

K3d commands:-

# See K3d version after installation
k3d version

Create a local (cluster-name) as dev-cluster with 1 master server and 2 worker agents with expose ports 80 (http) and 443 (https) for the load balancer within the k3d cluster

k3d cluster create dev-cluster -p "80:80@loadbalancer" -p "443:443@loadbalancer" --servers 1 --agents 2

To run you local or custom image in k3d cluster

  • Import the image into your cluster (e.g., dev-cluster)
k3d --cluster <cluster-name> image import <image-name>:<image-tag>

e.g.,

k3d --cluster dev-cluster image import <image-name>:<image-tag>
# OR
k3d -c dev-cluster image import <image-name>:<image-tag>

OR

k3d --cluster <cluster-name> images import <image-name-1>:<image-tag-1> <image-name-2>:<image-tag-2>

e.g.,

k3d --cluster dev-cluster images import <image-name-1>:<image-tag-1> <image-name-2>:<image-tag-2>
# OR
k3d -c dev-cluster images import <image-name-1>:<image-tag-1> <image-name-2>:<image-tag-2>

To see if the images are imported into k3d cluster

docker exec k3d-<cluster-name>-server-<number> crictl images
# OR
docker exec k3d-<cluster-name>-agent-<number> crictl images

e.g., To see images present in K3d: dev-cluster

docker exec k3d-dev-cluster-server-0 crictl images

NOTE: If using image-tag as:latest then please set imagePullPolicy: Never in the manifests yaml files, It's a K3d issue


List the local clusters

k3d cluster list
# OR
k3d cluster ls

Stop the local development-cluster

k3d cluster stop dev-cluster

Start a local development-cluster

k3d cluster start dev-cluster

Delete a local development-cluster

k3d cluster delete dev-cluster

K3d list nodes

k3d node list

Using kubectl on k3d local-cluster

kubectl cluster-info
# OR
kubectl cluster-info dump

Using kubectl commands

# Display the cluster events
k get events
# Display the cluster config
k config view
# Display list of contexts
k config get-contexts
# Display the current-context
k config current-context
# Set the default context to k3d <cluster-name>
k config use-context dev-cluster
# List all nodes in all namespaces
k get nodes -A
# List all services in all namespaces
k get services -A
k get svc -A
# List all deployments in all namespaces
k get deploy -A
# List all pods in all namespaces
k get pods -A
# List all configmaps in all namespaces
k get configmaps -A
# List all secrets in all namespaces
k get secrets -A
# Watch all pods
k get pods -w -o wide
# Watch all deployments
k get deploy -w -o wide
# Watch all services
k get svc -w -o wide
# Watch all configmaps
k get configmaps -w -o wide
# Create kubectl resources
k apply -f <yaml-file-path>
# Delete kubectl resources
k delete -f <yaml-file-path>
# Delete kubectl specific resources
k delete -f <deploymnet-service-file.yaml>
k delete -f <config-maps-file.yaml>

About

Local developemt setup for a Kubernetes cluster

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published