Originally posted here: https://blog.getambassador.io/super-fast-inner-development-loops-for-kubernetes-with-skaffold-and-telepresence-1cd3e42ba665
In this tutorial we'll run two different versions of the app in two different clusters. One version will emulate the production environment. The other will be where we'll do development.
-
Start the production cluster with minikube.
minikube start --profile prod-cluster
-
Run
kubectl proxy
in the background so we can get access to our prod service later.nohup kubectl proxy &
-
Skaffold can be used to build our image and deploy the app in one command. In this case we'll use the Skaffold Profile
prod
that is configured from production.skaffold run --profile prod
In the next session we'll set up a development cluster and iterate on the changes we want to make for our app.
-
Start the development cluster with minikube.
minikube start --profile dev-cluster
-
Click Cloud Code in the status bar
-
Select Run on Kubernetes, confirm that you want to use the "dev-cluster" context
-
Once your app is deployed, launch it with the link displayed in your Output panel, near the text
http://localhost:8080 Update successful
You can open the web preview by clicking the button and selecting "Preview on port 8080".
-
Open the HelloWorld.js file and change it to say
Hello From Skaffold!
. -
Save the file. You should see Skaffold sync your chanes to the running container and reload the app autoamtically in the Output panel.
-
Next, we'll make a bit bigger of a chance by changing the version of a dependency. Open the package.json file and downgrade the version of React from
16.13.1
to16.13.0
.This change requires a rebuild of the Docker image so you'll see Skaffold do a full rebuild of your image and then redeploy your changes by updating the Kubernetes manifests to point to the newly built image.
You've now seen the tight feedback loop you can create when using Skaffold and Cloud Code. Up next we'll leverage Telepresence to start receiving some of the production traffic on this development version
-
Switch to the prodcution cluster's Kubernetes context:
kubectx prod-cluster
-
Download the Telepresence binary
sudo curl -fL https://app.getambassador.io/download/tel2/linux/amd64/latest/telepresence -o /usr/local/bin/telepresence sudo chmod +x /usr/local/bin/telepresence
-
Check that you can access the service by using Web Preview. Hold the Ctrl and click the link output by this command.
echo http://localhost:8001/api/v1/namespaces/default/services/node/proxy/