An application that implements infinite loop stages:
- Coding - create server
To build and start Golang server:
go build -o bin/app src/main.go
bin/app
- Testing - server testing
curl localhost:8080
Output:
<pre>
<a href="bin/">bin/</a>
<a href="html/">html/</a>
<a href="src/">src/</a>
</pre>
- Build - add index.html
- Coding - configuration
Again build and start Golang server after adding changes:
go build -o bin/app src/main.go
bin/app
curl localhost:8080
Output:
<!DOCTYPE html>
<html>
*** Content of our index.html file ***
</html>%
- Testing - manual testing
Go to "localhost:8080" in the browser and check if everything works and index.html is displayed on the page.
-
Delivery:
- Create Dockerfile
cd src go mod init sdlc-project
- Build image
docker build .
- Run container on port 8080
docker run -p 8080:8080 sha256:(container id)
- Add image tag
docker tag sha256:(container id) (docker hub username)/app:v1.0.0
- Push to Docker Hub
docker push (docker hub username)/app:v1.0.0
-
Deployment - Kubernetes deployment
This step involves installing minikube or k3d for local Kubernetes deployment.
Create kubernetes deployment from image deployed on Docker Hub:
kubectl create deployment sdlc-project --image (docker hub username)/app:v1.0.0
Let's create port-forwarding to check if it works:
kubectl port-forward deployment/sdlc-project 8080
-
Operations - cover this stage using Kubernetes ecosystem
-
Coding - add new changes
-
Delivery:
- Build image
docker build . -t (docker hub username)/app:v1.0.1
- Push to Docker Hub
docker push docker.io/(docker hub username)/app:v1.0.1
-
Deployment - zero downtime deployment with Kubernetes
kubectl set image deployment sdlc-project app=(docker hub username)/app:v1.0.1
- Testing - manual testing
Go to "localhost:8080" in the browser and check if a new version exist.