From f0eb8884b64a88596f2532e7f3709a8c3cdd373e Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Thu, 2 Dec 2021 21:55:42 +0100 Subject: [PATCH] Update readme --- README.md | 82 ++++++++++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index b338ca2..7177baf 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,60 @@ -# Kluster (In Progress) +# Kluster -An operator that we are writing in the YouTube channel (https://youtu.be/89PdRvRUcPU) +A example Kubernetes operator to create Kubernetes cluster on DigitalOcean. +Once the operator is running, and we create a Kluster K8S resource in a cluster, a DigitalOcean Kubernetes +cluster would be created with provided configuration. -viveksingh.dev -v1alpha1 +This operator was written as part of one of my [YouTube playlist](https://www.youtube.com/watch?v=89PdRvRUcPU&list=PLh4KH3LtJvRTtFWz1WGlyDa7cKjj2Sns0). -generate +Here is an example of the Kluster resource -1. deep copy objects -2. clientset -3. informers -4. lister - -# Commands that we used +``` +apiVersion: viveksingh.dev/v1alpha1 +kind: Kluster +metadata: + name: kluster-0 +spec: + name: kluster-0 + region: "nyc1" + version: "1.21.3-do.0" + tokenSecret: "default/dosecret" # secret that has DigitalOcean token + nodePools: + - count: 3 + name: "dummy-nodepool" + size: "s-2vcpu-2gb" +``` -Should be run from root dir of project. +# Deploy on a Kubernetes cluster -## Code generator +Execute below command, from root of the repo -Make sure you have installed code generator +Create Kluster CRD ``` -execDir=~/go/src/k8s.io/code-generator -"${execDir}"/generate-groups.sh all github.com/viveksinghggits/kluster/pkg/client github.com/viveksinghggits/kluster/pkg/apis viveksingh.dev:v1alpha1 --go-header-file "${execDir}"/hack/boilerplate.go.txt +kubectl create -f manifests/viveksingh.dev_klusters.yaml ``` -## CRDs +Create RBAC resources and deployment ``` -controller-gen paths=github.com/viveksinghggits/kluster/pkg/apis/viveksingh.dev/v1alpha1 crd:trivialVersions=true crd:crdVersions=v1 output:crd:artifacts:config=manifests +kubectl create -f manifests/install/ ``` +# Create a secret with DigitalOcean token +To call DigitalOcean APIs we will have to create a secret with DigitalOcean token that +will be used in the Kluster CR that we create. +``` +kubectl create secret generic dosecret --from-literal token= +``` -apiVersion -kind -metadata: -spec: - ... - ... -status: - clusterId - progress - kubeconfig - - - -role-test: - resources: Kluster/status - -resource - apis/apps/v1/namespaces//deployments - v1/namespaces//pods// - - -pods logs - -logs subresources - v1/namespaces//pods//logs - +# Create a kluster CR +Create the kluster resource to create a k8s cluster in DigitalOcean +``` +kubectl create -f manifests/klusterone.yaml +```