DEV Community

Cover image for Setup Kubectl on Cloud Dev Environment in 60 Seconds
Siddhant Khare
Siddhant Khare

Posted on

Setup Kubectl on Cloud Dev Environment in 60 Seconds

This blog will describe how to automate the kubectl setup for Cloud Dev Environments such as Gitpod.

Why is it necessary to automate?

Gitpod offers an ephemeral environment. If you want to use kubectl on each/all workspaces, it must be configured. As a result, you won't have to manually install and configure kubectl every time you start working on it.

What is Ephemeral Environment?

An ephemeral environment is a short-lived, encapsulated deployment of an application. Ephemeral environments provide robust, on-demand platforms for running tests, previewing features, and collaborating asynchronously across teams. (Ref. here)

TL;DR; these are "Dynamic environments", "Temporary environments", "on-demand environments" or "short-lived environments".

Pre-Baked Dev Environment

Gitpod gives users the ability to construct pre-baked (ready to use) environments by offering .gitpod.yml that automate the configuration of the development environment. In order to avoid having to set up everything from scratch, users save time and experience less friction in their lives.

Automate kubectl setup

You only need two files to complete this task: your .gitpod.yml file and a script that executes the setup and installation of kubectl along with all other necessary tools.

  • First, You need to copy-paste this script in any directory of that particular project.

  • Now, You need to execute this script from your .gitpod.yml (present in the root of your project).


tasks:
  - name: Setup kubectl
    command: bash $GITPOD_REPO_ROOT/setup_kubectl_with_gitpod.sh
Enter fullscreen mode Exit fullscreen mode

You can configure the path based on where the setup kubectl script is located because my script was located in the root directory in this case.

Try Now

In less than 40 seconds, start using kubectl by clicking the button below.:

Code

Talk is cheap, show me the code

GitHub logo gitpod-samples / demo-kubectl-with-gitpod

Learn how to integrate Kubectl with Gitpod.


Related Repositories

GitHub logo gitpod-samples / demo-aws-with-gitpod

Learn how to integrate AWS Single Sign-On (SSO) and Amazon Elastic Container Registry (ECR) with Gitpod.

Gitpod with AWS

This repository contains an example of how to integrate AWS Single Sign-On (SSO) and Amazon Elastic Container Registry (ECR) with Gitpod.

Demo

Configure Secrets & Hit Below button:

Secret Management

Secrets Key-Value Map

sso_start_url = ${AWS_SSO_URL}
sso_region = ${AWS_SSO_REGION}
sso_account_id = ${AWS_ACCOUNT_ID}
sso_role_name = ${AWS_ROLE_NAME}
region = ${AWS_REGION}
Enter fullscreen mode Exit fullscreen mode

Configure secrets

  • Configure the following secrets here in Gitpod settings:

    • AWS_SSO_URL
    • AWS_SSO_REGION
    • AWS_ACCOUNT_ID
    • AWS_ROLE_NAME
    • AWS_REGION

    Note: You Can set scope at for all worskapces (⚠️) or at your Org. Level, at your Personal username level, or at Just Repo. Level. Read More: Configure Environment Variables

  • Maybe you use vault or some other secret storage, that's okay. The key is to inject them into the config when the workspace starts.

🚀 Now, You are ready to use AWS CLI, & With that, you can log in to your SSO or Use AWS ECR to use Private…


GitHub logo gitpod-samples / demo-dotfiles-with-gitpod

Learn how to bring your own dotfiles to Gitpod | Bring your own Dotfiles to Gitpod | dotfiles on Gitpod

Bring your Dotfiles to Gitpod

Ever wondered how you can bring your personal dotfiles configurations to Gitpod to have your personalized ephemeral developer environments in the cloud? Here's how...

How Does this Repo. Works?

  • It has a ./setup.sh file that contains the initial setup script to execute all the scripts to install/ configure required services under ./scripts/ to keep that X service installed on your next Gitpod Workspaces. For example, it contains following scripts
    • ./scripts/gpg_configure.sh is script to configure GPG key.
    • ./scripts/terraform_configure.sh is script to setup & configure Terraform.
    • ./scripts/aws_cli_install.sh to install AWS CLI.
    • ./scripts/deno_configure.sh to install & configure deno.
    • ./scripts/gcloud_cli_install.sh to install Google Cloud CLI.

How You Can Quickly Use this dotfiles with your Gitpod Workspaces (as template)


GitHub logo gitpod-samples / demo-tailscale-with-gitpod

Ever wondered how to configure Tailscale with Gitpod to enable secure and ephemeral developer environments in the cloud? Here's how...

Tailscale with Gitpod

Tailscale allows Gitpod CDE workspaces to access private private resources such as databases, S3 buckets, local services, etc.

Demo

Tailscale setup:

Tailscale hello service

  • Verify that reaching the example Tailscale hello application via ping fails.

Gitpod workspace

  • Click the button below to start a new development environment:

Open in Gitpod

  • Login to your Tailscale account when prompted from the Gitpod workspace terminal:
To authenticate, visit:
        https://login.tailscale.com/a/XXXXXXXXXXXX
  • Verify that reaching the example Tailscale hello application via ping succeeds.



Top comments (0)