This repository provides a test Ruby application which will listen on port 80,
Helm Chart and CI/CD to build and deploy it to minikube. Application is located
in the app
folder; check out Application Readme for more
information
To reproduce the setup, following tools are required:
Application is packed into Docker container and intended to be installed into Kubernetes via Helm Chart. Helm chart installs following Kubernetes resources:
- Deployment
- Service (for minikube I use NodePort type)
- Ingress (if enabled)
High Availability is reached by putting application pods behind the load balancer(in our case Kubernetes Service and/or Ingress) and scaling them to the desired amount(i.e. 3 replicas)
Security is achieved by running the application as a non-root user and enforcing containers to be immutable.
Docker images are built automatically, via GitHub Action 'Build docker image' This workflow is triggered on the following events:
- Push to master when a file in
app
folder is modified - Push of new tags
- Push to pull request to master, when a file in
app
folder is modified
CI workflow uses SEMVER
approach for tagging Docker images. Tags
will be assigned in the following way:
Event | Ref | Docker Tags |
---|---|---|
pull_request |
refs/pull/2/merge |
pr-2 |
push |
refs/heads/master |
master |
push |
refs/heads/releases/v1 |
releases-v1 |
push tag |
refs/tags/v1.2.3 |
1.2.3 , 1.2 , latest |
push tag |
refs/tags/v2.0.8-beta.67 |
2.0.8-beta.67 |
Also on each push GitHub Action 'Lint Codebase' will be triggered. This action uses GitHub Super-Linter under the hood and will run a set of linters against detected languages.
Since this is a test application, intended to be deployed to minikube, it's not possible to realize automated deployment. In real life, I would use GitHub Actions/ Jenkins/Terraform or other tools, depending on requirements.
Helm chart can be deployed manually via:
# Verify that Helm Chart renders correctly:
helm install --dry-run http-server helm/chart
# Install the chart
helm install http-server helm/chart
- Install Prerequisites
- Fork my github repo
https://github.com/sbulav/test-ruby-app
- Create new Personal Access Token
- Create 2 repository secrets:
- DOCKERHUB_USERNAME - Username of Docker hub user
- DOCKERHUB_TOKEN - Personal Access Token of Docker Hub user
- Start minikube by running following command:
minikube start
- Enable minikube Ingress:
minikube addons enable ingress
- Clone repository to your local development machine:
git clone [email protected]:<USERNAME>/test-ruby-app.git
- Amend Helm values
helm/chart/values.yaml
to your need - Issue a new tag:
git tag v1.0.0
git push --tags
Check out repository Github Actions and make sure that new Docker image is built and pushed to docker hub. 10. Install Helm chart.
# Verify that Helm Chart renders correctly:
helm install --dry-run http-server helm/chart
# Install the chart
helm install http-server helm/chart
Or install specific Image tag:
helm install http-server helm/chart --set tag=1.0.0
- Wait until the application is up and running and open web page in browser:
minikube service http-server
- (Optional) Access application via Ingress:
# Create DNS entry OR entry in /etc/hosts
sudo echo "$(minikube ip) http-server.local" >> /etc/hosts
Access application via browser or curl:
$ curl http-server.local.
Well, hello there!