Using Waypoint as my new application deployment
I have been using Kubernetes for a while and to run applications on Kubernetes, I would usually need to first create a docker file for my application and a Kubernetes Deployment file to structure and deploy my conatinerised application.
However, with the release of Waypoint by Hashicorp, I have found it much simpler to build and deploy my applications especially if my deployment end point is Kubernetes.
For example, I currently have written a Go Application which utilises Swagger. Previously without the use of Waypoint, I would have to write a Docker file in which I would have to include in the various dependecies used by my Go Application (for example swaggo/gin-swagger, gin-gonic/gin). I would then need to build a local image of my application and then push to Docker Hub (or any application repo for that matter). Finally, I would have to write a Kubernetes Deployment file to pull the application image which I have just build and run the Kubernetes Create -f command to deploy my services and my Deployment.
Now, to run a simple application, it really does sound like a lot of work. Furthermore, if I want to script all of these, I would have to write some form of bash script or some CI/CD code in Jenkins to string all the above mentioned items.
Instead, Waypoint offers me an alternative to simply deploy my applications on Kubernetes using cloud native build packs.
In this example, I have a simple CRUD application that is running the Go-Swagger capability as seen in the main.go file below.
I am now going to deploy this on Kubernetes using waypoint as my builder and deployment tool. First, we need to install Waypoint on Kubernetes. To do so we can execute the command below
waypoint install — platform=kubernetes -accept-tos
and our Waypoint service is up and ready to go
Next, we will create a Waypoint.hcl file in which we would declare the build and deployment mechanisms
project = “sample-go-app”app “sample-go-app” {
labels= {
“service” = “sample-go-app”,
“env” = “dev”
} build {
use “pack” {}
registry {
use "docker" {
image = "go-ps"
tag = "1"
local = true
}
}
} deploy {
use "kubernetes"{
service_port = 8080
}
} release {
use "kubernetes"{
load_balancer = true }
}
}
Let’s run the commands Waypoint init and Waypoint up
Waypoint init will initialise our repo and running Waypoint up will build our docker file and deploy to kubernetes as specified in our waypoint.hcl file. Once it has been deployed successfully, it will return the release and deployment URLs.
Now heading over to our deployment URL, we would see our application up and running.
All in all, Waypoint is kind an effective tool thus far. Stay tuned as I explore more about Waypoint .