dictybase-docker / cluster-management

BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Kevin's Cluster Exploration #154

Open ktun95 opened 3 months ago

ktun95 commented 3 months ago

Creating a GCloud Bucket

> gsutil mb gs://kops-kubernetes-state-playground

Basic Cluster Management

kops version v1.27.1 kubectl version v1.24.11

Creating a Cluster with kops

> kops create cluster --name=dicty-playground.k8s.local --zones us-central1-a 
> kops update cluster

Deleting a Cluster with kops

> kops delete cluster

Deploying an Nginx server

> kubectl create deployment my-nginx --image=nginx --replicas=1 --port=80
> kubectl expose deployment my-nginx --port=80 --type=LoadBalancer

Verification

> kubectl get svc my-nginx

NAME       TYPE           CLUSTER-IP      EXTERNAL-IP    PORT(S)        AGE
my-nginx   LoadBalancer   100.69.92.166   34.27.199.43   80:31629/TCP   36m

Visiting EXTERNAL-IP in web browser verifies thatthat the server is running and exposed.

Clean up

> kubectl delete svc my-nginx
> kubectl delete deploy my-nginx

Allocating Resources

Checking Available Node Resources

> kubectl get nodes
NAME                               STATUS   ROLES           AGE   VERSION
control-plane-us-central1-a-6phb   Ready    control-plane   46m   v1.28.11
nodes-us-central1-a-03z2           Ready    node            44m   v1.28.11
> kubectl describe node nodes-us-central1-a-03z2

Increasing the Number of Nodes in the Cluster

"An instance group is a collection of virtual machine (VM) instances that you can manage as a single entity." (https://cloud.google.com/compute/docs/instance-groups)

Checking the Current Instance Groups

> kops get instancegroups
NAME                ROLE        MACHINETYPE MIN MAX ZONES
control-plane-us-central1-a ControlPlane    e2-medium   1   1   us-central1-a
nodes-us-central1-a     Node        e2-medium   1   1   us-central1-a

Increasing the maxSize and minSize Properties

> kops edit instancegroup nodes-us-central1-a

spec.minSize 1 --> 3 spec.minSize 1 --> 3

Applying the Changes to the Cluster

> kops update cluster --yes

Verifying the Changes

> kubectl get nodes
NAME                               STATUS   ROLES           AGE     VERSION
control-plane-us-central1-a-k4fs   Ready    control-plane   4h58m   v1.27.15
nodes-us-central1-a-4grk           Ready    node            3m30s   v1.27.15
nodes-us-central1-a-bh3z           Ready    node            4h53m   v1.27.15
nodes-us-central1-a-pnmz           Ready    node            3m25s   v1.27.15
> kops get instancegroups
NAME                ROLE        MACHINETYPE MIN MAX ZONES
control-plane-us-central1-a ControlPlane    e2-medium   1   1   us-central1-a
nodes-us-central1-a     Node        e2-medium   3   3   us-central1-a

Applying default CPU and Memory Limits/Requests

from "./resources/memory-defaults.yaml":

apiVersion: v1
kind: LimitRange
metadata:
  name: mem-limit-range
spec:
  limits:
  - default:
      memory: 2G
      cpu: 2
    defaultRequest:
      memory: 256Mi
    type: Container

run:

> kubectl apply -f ./resources/memory-defaults.yaml 

Sets the default limit for the CPU and Memory to 2 CPUs and 2 Gigabytes of memory respectively.

Changing # of Pod Replicas

Creating the Deployments

> kubectl create deployment static-frontpage --image=dictybase/dicty-frontpage:develop-b797f75 --replicas=3 --port=3000
> kubectl get pods
NAME                                READY   STATUS    RESTARTS   AGE
static-frontpage-7958fbfc78-r8fzr   1/1     Running   0          26s
static-frontpage-7958fbfc78-tm6d5   1/1     Running   0          26s
static-frontpage-7958fbfc78-tn4rs   1/1     Running   0          29m

Reduce Number of Desired Replicas

> kubectl scale deployment/static-frontpage --replicas=1 
> kubectl get pods
NAME                                READY   STATUS    RESTARTS   AGE
static-frontpage-7958fbfc78-tn4rs   1/1     Running   0          29m

Clean up

> kubectl delete svc static-frontpage
> kubectl delete deploy static-frontpage

Running a Static Server in a Pod

> kubectl create deployment static-frontpage --image=dictybase/dicty-frontpage:develop-b797f75 --replicas=1
> kubectl expose deployment my-nginx --port=3000 --type=LoadBalancer
> kubectl get svc
NAME               TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
kubernetes         ClusterIP      100.64.0.1     <none>        443/TCP          24h
static-frontpage   LoadBalancer   100.70.29.67   34.16.52.15   3000:30726/TCP   41s

Clean up

> kubectl delete svc static-frontpage
> kubectl delete deploy static-frontpage

Version Testing

kops version v1.27.2 kubectl version v1.24.11

  1. Create Cluster [OK]
  2. Update Cluster [OK]
  3. Validate Cluster [OK]
  4. Delete Cluster [OK]

kops version v1.27.3 kubectl version v1.24.11

  1. Create Cluster [OK]
  2. Update Cluster [OK]
  3. Validate Cluster [OK]
  4. Delete Cluster [OK]

kops version v1.28.0 kubectl version v1.24.11

  1. Create Cluster [OK]
  2. Update Cluster [OK]
  3. Validate Cluster [OK]
  4. Increase # of Nodes [OK]
  5. Delete Cluster [OK]

kops version v1.28.7 kubectl version v1.24.11

  1. Create Cluster [OK]
  2. Update Cluster [OK]
  3. Validate Cluster [OK]
  4. Increase # of Nodes [OK]
  5. Delete Cluster [OK]

kops version v1.29.0 kubectl version v1.24.11

  1. Create Cluster [OK]
  2. Update Cluster [OK]
  3. Validate Cluster [OK]
  4. Increase # of Nodes [OK]
  5. Delete Cluster [OK]

kops version v1.29.2 kubectl version v1.24.11

  1. Create Cluster [OK]
  2. Update Cluster [OK]
  3. Validate Cluster [OK]
  4. Increase # of Nodes [OK]
  5. Delete Cluster [OK]