This is a sample Kubernetes deployment associated with Jenkins automation. The payload of this application is a static web application created using Hugo.
Note that for the design decisions and design constraints please refer: docs/SPECS.md
.
├── Dockerfile
├── Jenkinsfile
├── LICENSE
├── README.md
├── coeus-intel
...
│ ├── public
...
├── docs
│ └── SPECS.md
├── jenkins-build.yaml
├── k8s
│ ├── helm
│ │ ├── coeus
│ │ │ ├── Chart.yaml
│ │ │ ├── charts
│ │ │ ├── templates
│ │ │ │ ├── NOTES.txt
│ │ │ │ ├── _helpers.tpl
│ │ │ │ ├── deployment.yaml
│ │ │ │ ├── hpa.yaml
│ │ │ │ ├── ingress.yaml
│ │ │ │ ├── service.yaml
│ │ │ │ ├── serviceaccount.yaml
│ │ │ │ └── tests
│ │ │ │ └── test-connection.yaml
│ │ │ └── values.yaml
│ │ └── coeus-0.1.0.tgz
│ └── raw
│ ├── README.md
│ └── coeus.yaml
└── nginx
└── default.conf
Following technologies has been associated to finalize the solution.
Technology | Purpose | Reference |
---|---|---|
Docker | To containerize the application | Dockerfile |
Kubernetes | To orchestrate the containers | k8s |
Helm | To manage the application releases | k8s/helm |
Jenkins | To implement the CI Pipeline | Jenkinsfile |
Dependencies:
- Kubernetes cluster
- Ingress controller to handle the web traffic (in this case Nginx-Ingress)
- Cert-Manager to automate the SSL certificates
- Pre-configured Namespace - optional
- Kubernetes secret to use when pulling the images from the repo - optional
- A Domain name (in this case coeus.bizkt.com.au)
- Kubectl installed
- Helm installed
To deploy the application manually,
- Clone the git repository
$git clone https://github.com/krishanthisera/coeus.git
- cd into the helm directory
$cd k8s/helm/coeus
- Install the release
$helm install -n <namespace> <release-name> . $#If ingress required to be disabled $helm install -n <namespace> <release-name> . --set ingress.enabled=false $helm ls -n coeus NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION coeus-app coeus 2 2020-12-17 04:27:27.718309171 +0000 UTC deployed coeus-0.1.0 1.16.0
To automate the deployment with Jenkins
- Install the Kubernetes plugin for Jenkins
- Configure the secrets on Jenkins
- Kubernetes secrets
- Secret to use with Docker registry
- Create a Jenkins Pipeline associating the GIT repository Note that following Jenkins environment variables can manipulate depending on the context
#URL for the Docker Registry. In this case a self hosted Docker registry has been used.
DOCKER_REGISTRY = 'https://shipping.bizkt.com.au:443'
DOCKER_REPO = 'shipping.bizkt.com.au:443/coeus/coeus'
#Jenkins secret for the repository
DOCKER_REPO_CREDENTIAL = 'shipping_admin'
RELEASE_NAME = 'coeus-app'
RELEASE_NAMESPACE = 'coeus'
APP_VERSION = '0.1'
#Note that, in this case, the build number will be appended to the Docker image's tag
GIT_REPO = 'https://github.com/krishanthisera/coeus.git'
Jenkins Kubernetes plugin has been associated to execute this pipeline. Prior to the configuration, please do ensure that relevant Service Account (associate with a Role and a RoleBinding) is created for Jenkins to access the cluster resource.
In most cases, it is recommended to explicitly mention the resource requirements (container's or POD's) in the manifest. In a scenario where the resource consumption of the PODs is unclear, it is recommended to Use Vertical POD Autoscaler (VPA) with GoldiLocks to make estimations.
Please see Design Specification for the further discussion.