This tutorial will walk you through the steps to deploy code-server using a secret password with persistent storage. I am using a Google Kubernetes Engine (GKE) cluster for the development and testing of this tutorial.
Replace <password>
in the following command with your desired password before running.
kubectl create secret generic secret-code-server --from-literal=PASSWORD='<password>'
Using persitent volumes will allow the code-server config and the code you develop to persist pod failures.
The pvc manifest file will:
- Assume that a default storage class is defined.
- Set persistent volumes to 1Gi.
kubectl apply -f code-server-pvc.yaml
The deployment manifest file will:
- Create a service with a loadbalancer ip and expose code-server on port 80 using HTTP.
- Deploy code-server pinned to version 'v3.4.0-ls46'
- Set a password as defined by the kubernetes secret named "secret-code-server" using the PASSWORD value.
- Mount the persistent volume to
/config
.
kubectl apply -f code-server-deployment.yaml
You can now access code-server using the service ip.
To get the IP address to access code-server.
kubectl get svc code-server -o=jsonpath={.status.loadBalancer.ingress[].ip}
Note: It may take a minute for the ip address to be assigned so be patient.
If you would like to clean-up the resources created during this tutorial.
kubectl delete -f code-server-deployment.yaml
kubectl delete -f code-server-pvc.yaml
kubectl delete secret secret-code-server