Go-gke-pulumi - A simple example that deploys a GKE cluster and an application to the cluster using pulumi

Deploy

Google Kubernetes Engine (GKE) Cluster

This example deploys a Google Cloud Platform (GCP) Google Kubernetes Engine (GKE) cluster and an application to it

Deploying the App

To deploy your infrastructure, follow the below steps.

Prerequisites

  1. Install Pulumi

  2. Install Go 1.13 or later

  3. Install Google Cloud SDK (gcloud)

  4. Configure GCP Auth

    • Login using gcloud

      $ gcloud auth login
      $ gcloud config set project <YOUR_GCP_PROJECT_HERE>
      $ gcloud auth application-default login

    Note: This auth mechanism is meant for inner loop developer workflows. If you want to run this example in an unattended service account setting, such as in CI/CD, please follow instructions to configure your service account. The service account must have the role Kubernetes Engine Admin / container.admin.

Steps

After cloning this repo, from this working directory, run these commands:

  1. Create a new Pulumi stack, which is an isolated deployment target for this example:

    This will initialize the Pulumi program in Golang.

    $ pulumi stack init
  2. Set the required GCP configuration variables:

    This sets configuration options and default values for our cluster.

    $ pulumi config set gcp:project <YOUR_GCP_PROJECT_HERE>
    $ pulumi config set gcp:zone us-west1-a     // any valid GCP Zone here
  3. Stand up the GKE cluster:

    To preview and deploy changes, run pulumi update and select "yes."

    The update sub-command shows a preview of the resources that will be created and prompts on whether to proceed with the deployment. Note that the stack itself is counted as a resource, though it does not correspond to a physical cloud resource.

    You can also run pulumi up --diff to see and inspect the diffs of the overall changes expected to take place.

    Running pulumi up will deploy the GKE cluster. Note, provisioning a new GKE cluster takes between 3-5 minutes.

    " Resources: + 2 created Duration: 3m3s">
    $ pulumi update
    Previewing update (dev):
    
        Type                      Name            Plan
    +   pulumi:pulumi:Stack       gcp-go-gke-dev  create
    +   └─ gcp:container:Cluster  helloworld      create
    
    Resources:
        + 2 to create
    
    Updating (dev):
    
        Type                      Name            Plan
    +   pulumi:pulumi:Stack       gcp-go-gke-dev  created
    +   └─ gcp:container:Cluster  helloworld      created
    
    Outputs:
        ClusterName: "helloworld-9b9530f"
        KubeConfig : "
         
          "
         
    
    Resources:
        + 2 created
    
    Duration: 3m3s
  4. After 3-5 minutes, your cluster will be ready, and the kubeconfig JSON you'll use to connect to the cluster will be available as an output.

  5. Access the Kubernetes Cluster using kubectl

    To access your new Kubernetes cluster using kubectl, we need to setup the kubeconfig file and download kubectl. We can leverage the Pulumi stack output in the CLI, as Pulumi facilitates exporting these objects for us.

    $ pulumi stack output kubeconfig --show-secrets > kubeconfig
    $ export KUBECONFIG=$PWD/kubeconfig
    
    $ kubectl version
    $ kubectl cluster-info
    $ kubectl get nodes
  6. Once you've finished experimenting, tear down your stack's resources by destroying and removing it:

    $ pulumi destroy --yes
    $ pulumi stack rm --yes
Owner
Snigdha Sambit Aryakumar
SRE @ Travix International | Helps building and delivering software faster
Snigdha Sambit Aryakumar
Similar Resources

Install hubble-ui on GKE Dataplane V2

GKE Hubble Export This is a grpc server wrapper that re-export the cilium agent's observer service and peer service from the local domain socket. And

Jan 2, 2023

A small utility to generate a kubectl configuration file for all clusters you have access to in GKE.

gke-config-helper A small utility to generate a kubectl configuration file for all clusters you have access to in GKE. Usage $ gke-config-helper The b

Feb 9, 2022

cluster-api-state-metrics (CASM) is a service that listens to the Kubernetes API server and generates metrics about the state of custom resource objects related of Kubernetes Cluster API.

Overview cluster-api-state-metrics (CASM) is a service that listens to the Kubernetes API server and generates metrics about the state of custom resou

Oct 27, 2022

Kubelet-bench - Example Go-based e2e benchmark for various Kubelet operations without spinning up whole K8s cluster

kubelet-bench An example of Go based e2e benchmark for various Kubelet operation

Mar 17, 2022

kubetnl tunnels TCP connections from within a Kubernetes cluster to a cluster-external endpoint, e.g. to your local machine. (the perfect complement to kubectl port-forward)

kubetnl kubetnl (kube tunnel) is a command line utility to tunnel TCP connections from within a Kubernetes to a cluster-external endpoint, e.g. to you

Dec 16, 2022

A pod scaler golang app that can scale replicas either inside of cluster or out of the cluster

pod-scaler A simple pod scaler golang application that can scale replicas via manipulating the deployment Technologies The project has been created us

Oct 24, 2021

Influxdb-cluster - InfluxDB Cluster for replacing InfluxDB Enterprise

InfluxDB ATTENTION: Around January 11th, 2019, master on this repository will be

Dec 26, 2022

A Terraform module to manage cluster authentication (aws-auth) for an Elastic Kubernetes (EKS) cluster on AWS.

Archive Notice The terraform-aws-modules/eks/aws v.18.20.0 release has brought back support aws-auth configmap! For this reason, I highly encourage us

Dec 4, 2022

Simple example using Git actions + Argo CD + K8S + Docker and GO lang

CICD-simple_example Simple example using Git actions + Argo CD + K8S + Docker and GO lang Intro Pre reqs Have an ArgoCD account and Installed. Docker

Oct 28, 2021
Pulumi-k8s-operator-example - OpenGitOps Compliant Pulumi Kubernetes Operator Example

Pulumi GitOps Example OpenGitOps Compliant Pulumi Kubernetes Operator Example Pr

May 6, 2022
Simple-go-api - This porject deploys a simple go app inside a EKS Cluster

SimpleGoApp This porject deploys a simple go app inside a EKS Cluster Prerequisi

Jan 19, 2022
This repo contains example on how to consume secrets from Google Secret Manager from GKE

GKE Secret Manager. Environment setup This repo contains examples of how to consume secrets from Google Secret Manager (GSM) from Google Kubernetes En

Dec 5, 2022
Pulumi-tencentcloud - Pulumi provider for tencentcloud

Terraform Bridge Provider Boilerplate This repository contains boilerplate code

Dec 30, 2021
Pulumi-awscontroltower - A Pulumi provider for AWS Control Tower

Terraform Bridge Provider Boilerplate This repository contains boilerplate code

Nov 14, 2022
Pulumi-hcp - A Pulumi provider for interacting with the Hashicorp Cloud Platform

Terraform Bridge Provider Boilerplate This repository contains boilerplate code

Dec 5, 2022
Keep updated about all deploys on Tsuru

Snitch Keep updated about each deploy via Tsuru. This program will notify your team and many tools when someone has deployed any application via Tsuru

Sep 27, 2022
In this repository, the development of the gardener extension, which deploys the flux controllers automatically to shoot clusters, takes place.

Gardener Extension for Flux Project Gardener implements the automated management and operation of Kubernetes clusters as a service. Its main principle

Dec 3, 2022
The example shows how to build a simple multi-tier web application using Kubernetes and Docker
The example shows how to build a simple multi-tier web application using Kubernetes and Docker

Guestbook Example This example shows how to build a simple multi-tier web application using Kubernetes and Docker. The application consists of a web f

Nov 15, 2021
An operator for managing ephemeral clusters in GKE

Test Cluster Operator for GKE This operator provides an API-driven cluster provisioning for integration and performance testing of software that integ

Oct 22, 2022