|
| 1 | +# GCP CCM with kOps Quickstart |
| 2 | + |
| 3 | +This guide provides a quickstart for building and deploying the GCP Cloud Controller Manager (CCM) to a self-managed Kubernetes cluster provisioned with kOps. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +A Google Cloud Platform project with billing enabled. |
| 8 | + |
| 9 | +## Deployment |
| 10 | + |
| 11 | +The `make kops-up` target is an end-to-end workflow that automatically: |
| 12 | +- Provisions a Kubernetes cluster using kOps. |
| 13 | +- Builds the CCM image locally. |
| 14 | +- Pushes the image to your Artifact Registry. |
| 15 | +- Deploys the CCM (along with required RBAC) to the cluster. |
| 16 | + |
| 17 | +Run the following commands to get started: |
| 18 | + |
| 19 | +```sh |
| 20 | +# Enable required GCP APIs |
| 21 | +gcloud services enable compute.googleapis.com |
| 22 | +gcloud services enable artifactregistry.googleapis.com |
| 23 | + |
| 24 | +# Set environment variables |
| 25 | +export GCP_PROJECT=$(gcloud config get-value project) |
| 26 | +export GCP_LOCATION=us-central1 |
| 27 | +export GCP_ZONES=${GCP_LOCATION}-a |
| 28 | +export KOPS_CLUSTER_NAME=kops.k8s.local |
| 29 | +export KOPS_STATE_STORE=gs://${GCP_PROJECT}-kops-state |
| 30 | + |
| 31 | +# Create the state store bucket if it doesn't already exist |
| 32 | +gcloud storage buckets create ${KOPS_STATE_STORE} --location=${GCP_LOCATION} || true |
| 33 | + |
| 34 | +# Run the cluster creation target, may take several minutes |
| 35 | +make kops-up |
| 36 | +``` |
| 37 | + |
| 38 | +## Verification |
| 39 | + |
| 40 | +To verify that the Cloud Controller Manager is running successfully: |
| 41 | + |
| 42 | +1. **Check the Pod Status**: Verify the pod is `Running` in the `kube-system` namespace. |
| 43 | +```sh |
| 44 | +kubectl get pods -n kube-system -l component=cloud-controller-manager |
| 45 | +``` |
| 46 | + |
| 47 | +2. **Check Pod Logs**: Look for any errors or access and authentication issues with the GCP API. |
| 48 | +```sh |
| 49 | +kubectl logs -n kube-system -l component=cloud-controller-manager |
| 50 | +``` |
| 51 | + |
| 52 | +3. **Check Node Initialization**: The CCM should remove the `node.cloudprovider.kubernetes.io/uninitialized` taint once it successfully fetches the node's properties from the GCP API. |
| 53 | +```sh |
| 54 | +# Ensure no nodes have the uninitialized taint, output should be empty. |
| 55 | +kubectl get nodes -o custom-columns=NAME:.metadata.name,TAINTS:.spec.taints | grep uninitialized |
| 56 | +``` |
| 57 | + |
| 58 | +4. **Verify ProviderID**: Check if your nodes are correctly populated with GCP-specific data (e.g., `ProviderID` in the format `gce://...`). |
| 59 | +```sh |
| 60 | +kubectl describe nodes | grep "ProviderID:" |
| 61 | +``` |
| 62 | + |
| 63 | +## Teardown |
| 64 | + |
| 65 | +To tear down the cluster and clean up resources: |
| 66 | + |
| 67 | +```sh |
| 68 | +make kops-down |
| 69 | +``` |
0 commit comments