This is a sample project for demo purposes, providing a simple RESTful API with a simple HTTP POST endpoint.
It shows how to
- package a Spring Boot app into a Docker image, using Skaffold and Google Jib;
- Deploy it into your Kubernetes cluster.
You will need the following in your system:
- Skaffold 0.15.0 or better
- Kubectl 1.17.0 or better
- a local Kubernetes cluster like Docker for Desktop CE or Minikube if you want to develop with your local cluster.
(Note: if you want to work directly with your remote AWS cluster, having a local cluster is not strictly needed but strongly advised!)
- If your are a Visual Studio Code user, install Google Cloud Code extension for VS Code
- If you have IntelliJ, use Google Cloud Code for IntelliJ
- Develop Faster on Kubernetes With Google Container Tools and Cloud Build (Cloud Next '19)
- Super-charge your GKE Developer Workflow in Visual Studio Code and IntelliJ (Cloud Next '19)
Set your context (use "" if you want to use your local docker daemon registry cache and avoid to deploy to a remote private registry):
Please take a look at Skaffold docs for more commands and configurations!
You can run the following commands by terminal or use the facilities provided by IDE(s).
You code in your IDE while the system listen for changes and build/redeploys to your cluster in background.
skaffold dev
(Note: you can tune the timeouts :))
You code in your IDEs and deploy/run explicitly by typing:
skaffold run --tag=dev
(Note: if you don't specify the tag, then the latest
will be used: keep this in mind with your K8S deployments!)
Happy coding!
skaffold delete
You have to do the docker login first and then run Skaffold. For example, when using AWS CLI v2 (as always, change account id and region):
mario@Sharkey:~/src/medium-articles/aws-k8s-hello-world$ aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin xxxxxxxxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com
Login Succeeded
mario@Sharkey:~/src/medium-articles/aws-k8s-hello-world$ skaffold run -p aws --tag=dev --default-repo xxxxxxxxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/hello-world-app
Generating tags...
- hello-world -> xxxxxxxxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/hello-world-app/hello-world:dev
Checking cache...
- hello-world: Found. Pushing
...
...