Skip to content

PoC for remote SSH development on dev containers deployed in Kubernetes using DevSpace

License

Notifications You must be signed in to change notification settings

fkurz/devspace-ssh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

devspace-ssh

PoC for remote SSH development on dev containers deployed in Kubernetes using DevSpace

Set up

1. Install Tooling

  • Terraform
  • AWS CLI
  • DevSpace
  • Kubectl
  • Helm

2. Create an EKS cluster on AWS with Terraform

cd /home/dev
aws configure set aws_access_key_id <the-access-key-id>
aws configure set aws_secret_access_key <the-secret-access-key>
aws configure set default.region eu-central-1
aws configure set default.output json
export TF_VAR_region="$(aws configure get default.region)"
terraform -chdir=terraform init
terraform -chdir=terraform apply 

Confirm that you want to create the resources.

ℹ️ <the-access-key-id> and <the-secret-access-key> have to be a valid credential pair authorized to create an AWS EKS cluster, AWS ECR registry and related infrastructure.

With the infrastructure in place, point kubectl to the created EKS cluster.

THE_REGION="$(terraform -chdir=terraform output -raw region)"
THE_CLUSTER_NAME="$(terraform -chdir=terraform output -raw cluster_name)"
aws eks --region "$THE_REGION" update-kubeconfig --name "$THE_CLUSTER_NAME"

3. Make dev container image available inside the cluster

Log in to the ECR

THE_ECR_REPOSITORY_URL="$(terraform -chdir=terraform output -raw repository_url)"
aws ecr get-login-password --region "$THE_REGION" | docker login --username AWS --password-stdin "$THE_ECR_REPOSITORY_URL"

Build and push the dev container image

docker buildx build --platform linux/amd64 --tag "${THE_ECR_REPOSITORY_URL}:latest" --file docker/devcontainer.Dockerfile --push .

4. Start a dev container on the ECR cluster with DevSpace

devspace use context "$(kubectl config current-context)"
kubectl create ns devspace
devspace use namespace devspace

Deploy your dev container to the remote cluster with DevSpace:

devspace dev --var THE_DEV_CONTAINER_IMAGE="${THE_ECR_REPOSITORY_URL}:latest"

Verify that we are actually running a command on the DevSpace pod, by running

$ ssh the-dev-container.devspace.devspace 'hostname'
the-dev-container-devspace-847f75dd44-s8m4l

The output should be the name of the pod created by DevSpace.

Clean up

Stop the running DevSpace process and then run

devspace purge
aws ecr batch-delete-image --repository-name "$THE_ECR_REPOSITORY_NAME" --image-ids "$(aws ecr list-images --repository-name=$THE_ECR_REPOSITORY_NAME --query 'imageIds[*]')"
terraform -chdir=terraform destroy

Confirm that you want to destroy the deployed resources.

About

PoC for remote SSH development on dev containers deployed in Kubernetes using DevSpace

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published