Write Dockerfile to build the flask application to docker image
app.py and Dockerfile is in
flask-app
After building the image, Push it to the dockerhub registry in a private repo
db.yml and flask-php.yml files are in
docker-compose
-First, Create 2 self signed certificates:
The first certificate is to flask-app with domain name called
flask-app.local
The second certificate is to phpmyadmin with domain name called
phpmyadmin.local
Certs are in
docker-compose/nginx-proxy/certs
But first we need to put these domains in our /etc/hosts file to map them to the proxy to route them
Second, Create proxy file with the created ssl to be able to access our apps:
flask app on
flask-app.local
domain name
phpmyadmin on
phpmyadmin.local
domain name
proxy.yml is in
docker-compose
Now we are able to access our apps on these domains
Before we deploy our k8s files, We need to configure 2 things:
First, As our flask image is in a private repo in dockerhub registry, We need to create a Pull image secret to enable flask-deployment.yml to pull the image from the private dockerhub registry
We will do some steps:
1-
Create .docker-config.json file
Where auth attribute is
base64 of dockerhub-username:dockerhub-password
2-
Now,We can create our pull image secret
Where .dockerconfigjson attribute is
base64-encoded-contents-of-.docker/config.json file
3-
After creating the pull image secret,We must refer it into flask-deployment.yml
Now our flask deployment is able to pull the flask image from the private repo
Second
We need to add our minikube ip and our domain names to /etc/hosts to map these doamins to the minikube ingress controller to route them
All k8s files are in
gitlab-k8s
Now, We can access our apps on the specific domains
We installed gitlab with a docker-compose file to presist data,configration and logs
Acess gitlab UI
install-gitlab.yml is in
install-gitlab
Before we push our docker-compose files we need to configure 3 things:
First, Add docker login credentials in gitlab to enable docker-compose to pull the flask image from the private dockerhub registry
Second, We need to configure and add a runner to our project to execute pipelines commans on it
Our runner is active and running and ready to receive pipeline jobs
Third, Configure .gitlab-ci.yml file and write the pipeline
All docker-compose files,scripts and .gitlab-ci.yml file is on
gitlab-compose
Now,We are ready to deploy our docker-compose files
As soon as the docker compose files and .gitlab-ci.yml file are pushed to the gitlab repo, The pipeline will start
Pipeline ran successfully
Now, We can access our apps from Environmnent tab
Before we deploy our k8s files, We need to configure some things:
First, Create a dedicated service account with a dedicated permissions to use this service account to aceess minikube cluster and deploy k8s files
Second,Put the token of the secret file in kubeconfig file to be able to access the minikube cluster
To do that, We need first to create a secret token to the service account
Then we need the token from this secret file and convert it to bas64
Encode the token to base64
Finally, Add the encoded bas64 token to kubeconfig file
Now we have a kubeconfig file and can use it to access the minikube cluster and deploy k8s files
Add this kubeconfig file to gitlab to use it in our pipeline
gitlab service account files are in
gitlab-serviceaccount
We need also to configure and add a runner to our project to execute pipelines commans on it
Our runner is active and running and ready to receive pipeline jobs
All k8s files,scripts and .gitlab-ci.yml file is on
gitlab-k8s
Now,We are ready to deploy our k8s files
As soon as the k8s files and .gitlab-ci.yml file are pushed to the gitlab repo, The pipeline will start
Pipeline ran successfully
Now, We can access our apps from Environmnent tab
Stack Helm chart files is in
stack-chart
First, we need to install ArgoCD on our minikube cluster
Then, Froward ArgoCDd service to port 8080 to access ArgoCD UI
Finally, Get ArgoCD password to access the UI
After ArgoCD working, We can now apply ArgoCD-App.yml to configure and synchronize ArgoCD with Helm chart repo
ArgoCD-App.yml file is in
ArgoCD
After doing that ArgoCD become synchronized with Helm chart repo and changes in applications happens only from Helm chart repo