Code Monkey home page Code Monkey logo

gke-ssh's Introduction

Goal

Deploy an SSH bastion host based on an tweaked Helm chart [1] within a private GKE cluster to prove that can be publicly accessible via NLB and controllable via ACL.

This solution deploys all the infrastructure needed from scratch, from the Google project, the networking, the GKE up to the K8S deployment via Helm.

IMPORTANT: once destroyed, and in case you want to deploy it again, you'll need to set a new project name in config.env since it stays pending for deletion for 30 days so that Google can bill on the usage. [2]


Requirements

  1. Software: gmake, docker.
  2. GCP permissions to create new projects. [3]

This has been developed and tested using Cloud Shell. Since it is Docker based it can run anywhere. All the pakages and modules versions are hardcoded to make sure that the outcome is consistent.


Usage instructions

  1. Create a Google Storage bucket where to keep Terraform's state.
gsutil mb gs://<BUCKET_NAME>
  1. Edit the configuration files:
    • config.env (mandatory): you must set the bucket you just created in the previous state, the project to be created, the billing id associated and the user name and private SSH key. Create this file by copying the file config.env.tmpl
    • variables.tf (optional): by default it is deployed in europe-west4 but you can change this and other configuration parameters here.
  2. Execute the following commands.
# Builds and runs the Docker image
make all
# Returns Terraform's plan useful to check what is going to be deployed
make plan
# Deploys the resources via Terraform
make deploy
# Destroys the resources via Terraform
make destroy

IMPORTANT: every time you change config.env you must execute make all in order to reload the variables.


Pending

  • Add testing (terratest or builtin test).
  • Add post-exec to show the NLB endpoint.

References

[1] https://artifacthub.io/packages/helm/t3n/ssh-bastion

[2] https://cloud.google.com/resource-manager/docs/creating-managing-projects#shutting_down_projects

[3] https://cloud.google.com/resource-manager/docs/creating-managing-projects

gke-ssh's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

isabella232

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.