|
| 1 | +# Development |
| 2 | + |
| 3 | +This doc explains how to set up a development environment so you can get started contributing to this project |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. [`go`](https://golang.org/doc/install): For building the project |
| 8 | +1. [`git`](https://help.github.com/articles/set-up-git/): For source control |
| 9 | +1. [`gcloud`](https://cloud.google.com/sdk/docs/install): For Interacting with the Google Cloud Platform |
| 10 | + |
| 11 | +This guides breaks down into two parts |
| 12 | +1. Setting up the GKE cluster - If you have already setup the GKE cluster, you can skip this part |
| 13 | +2. Setting up the development environment - This part is required for all the contributors |
| 14 | + |
| 15 | +### Setting up the GKE cluster |
| 16 | + |
| 17 | +1. First Go ahead and create new project in the Google Cloud Platform and enable billing for the project if you don't have it already enabled. You can follow the below links as guide on how to create a new project and enable billing for the project |
| 18 | + - [Creating the project](https://cloud.google.com/resource-manager/docs/creating-managing-projects) |
| 19 | + - [Enable billing for given project](https://cloud.google.com/billing/docs/how-to/modify-project) |
| 20 | + |
| 21 | + |
| 22 | +2. Once you have created the project enable the below apis |
| 23 | + |
| 24 | + ``` |
| 25 | + gcloud services enable compute.googleapis.com |
| 26 | + gcloud services enable container.googleapis.com |
| 27 | + ``` |
| 28 | +
|
| 29 | +3. Next go ahead and create the service account in the project and assign the following role to the service account |
| 30 | +
|
| 31 | + - Kubernetes Engine Admin |
| 32 | + - Monitoring Admin |
| 33 | + - Service Account User |
| 34 | +
|
| 35 | +
|
| 36 | +4. Once you have assigned the roles to the service account, go ahead and create a new key for the service account by following this link as a guide [Creating and managing service account keys](https://cloud.google.com/iam/docs/creating-managing-service-account-keys) |
| 37 | +
|
| 38 | +
|
| 39 | + > Note : Make sure you have the service account key stored in a secure location and do not share it with anyone. |
| 40 | +
|
| 41 | +5. Now configure the gcloud sdk to use the service account key by running the below command |
| 42 | +
|
| 43 | + ``` |
| 44 | + gcloud auth activate-service-account --key-file /path/to/key.json |
| 45 | + ``` |
| 46 | +
|
| 47 | +6. First configure the required environment variable using the below command |
| 48 | +
|
| 49 | + ```bash |
| 50 | + export PROJECT_ID=<project-id> |
| 51 | + export CLUSTER_NAME=<cluster-name> |
| 52 | + export REGION=<region> |
| 53 | + ``` |
| 54 | +
|
| 55 | +7. Next create a GKE cluster using the below command |
| 56 | + ``` |
| 57 | + gcloud container clusters create $CLUSTER_NAME --location=$REGION --num-nodes 1 --machine-type=n1-standard-1 --disk-size=10 --project $PROJECT_ID |
| 58 | + ``` |
| 59 | +
|
| 60 | +
|
| 61 | +7. Once the cluster is created, go ahead and get the credentials for the cluster by running the below command |
| 62 | +
|
| 63 | + ``` |
| 64 | + gcloud container clusters get-credentials $CLUSTER_NAME --location=$REGION --project $PROJECT_ID |
| 65 | + ``` |
| 66 | +
|
| 67 | +8. Now export the generated kubeconfig file to the `KUBECONFIG` environment variable by running the below command |
| 68 | +
|
| 69 | +
|
| 70 | + ``` |
| 71 | + export KUBECONFIG=~/.kube/config |
| 72 | + ``` |
| 73 | +
|
| 74 | +
|
| 75 | +9. Next export the service account key to the `GOOGLE_APPLICATION_CREDENTIALS` environment variable by running the below command |
| 76 | +
|
| 77 | +
|
| 78 | + ``` |
| 79 | + export GOOGLE_APPLICATION_CREDENTIALS="/path/to/key.json" |
| 80 | + ``` |
| 81 | +
|
| 82 | +### Setting up the development environment |
| 83 | +
|
| 84 | +1. If you already setup the PROJECT_ID ,REGION and CLUSTER_NAME environment variables in the while setting up the GKE cluster, you can skip this step. If not, go ahead and export the below environment variables |
| 85 | +
|
| 86 | + ```bash |
| 87 | + export PROJECT_ID=<project-id> |
| 88 | + export REGION=<region> |
| 89 | + export CLUSTER_NAME=<cluster-name> |
| 90 | + ``` |
| 91 | +
|
| 92 | +2. Once you have exported the environment variables, go ahead and install the CRDs for the karpenter by running the below command |
| 93 | +
|
| 94 | + ``` |
| 95 | + kubectl apply -f charts/karpenter/crds/ |
| 96 | + ``` |
| 97 | +
|
| 98 | +3. Once you have installed the CRDs, go ahead and install the karpenter by running the below command |
| 99 | + ``` |
| 100 | + make run |
| 101 | + ``` |
0 commit comments