Setup Kubernetes Cluster On GCP Using KOPS

0 107
  1. Open Cloud shell
  2. Lets first get KOPS binary in place
    1. Download binaries
      curl -Lo kops$(curl -s | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
    2. Give permission to KOPSpackage using:
      chmod +x ./kops
    3. Copy KOPS using:
      sudo mv ./kops /usr/local/bin/
  3. Installing kubectl
    1. Download kubectl using:
      curl -Lo kubectl$(curl -s
    2. Give permission to kubectl package using:
      chmod +x ./kubectl
    3. Copy kubectl using:
      sudo mv ./kubectl /usr/local/bin/kubectl
  4. Creating a state store
    1. kops needs a state store, to hold the configuration for your clusters. The simplest configuration for Google Cloud is to store it in a Google Cloud Storage bucket in the same account, so that’s how we’ll start. So, just create an empty bucket – you can use any (available) name
      gsutil mb gs://<Name of your choice>
    2. Further, rather than typing the –state argument every time, it’s much easier to export the KOPS_STATE_STORE environment variable:
      export KOPS_STATE_STORE=gs://<Name of bucket defined in step 1>
  5. Create SSH keys before creating cluster using:
  6. Creating our first cluster
    1. Lets first set a project in Cloud Shell:
      PROJECT=`gcloud config get-value project`
    2. To unlock the GCE features
      export KOPS_FEATURE_FLAGS=AlphaAllowGCE
    3. kops create cluster creates the Cluster object and InstanceGroup object you’ll be working with in kops:
      kops create cluster simple.k8s.local --zones us-central1-a --state ${KOPS_STATE_STORE}/ --project=${PROJECT}
    4. You can now list the Cluster objects in your kops state store
      kops get cluster --state ${KOPS_STATE_STORE}
    5. Starting it all
      kops update cluster simple.k8s.local --yes
  7. Deleting the cluster
    kops delete cluster simple.k8s.local --yes

Leave A Reply

Your email address will not be published.