The Staging Environment
The staging environment contains the Flask Application, Redis and MySQL within the staging K8s cluster’s default namespace.
MySQL is deployed without a persistent storage. Therefore, it will lose any information upon restart.
The secrets and config maps are also defined in this directory.
Create a GKE cluster
Create a cluster; name=cluster-1
Change the cluster name, project and GKE zone in the GitHub actions ci file
Add the regcred secret for docker registry config file
This config contains the credentials for the private docker registry.
This secret can be found here
https://docs.google.com/document/d/1wPSJVYKU5EWj_Lu7uTDaZhxoQJK2BvIB11MB7hpQfmQ/edit#
Spinup a cloud shell
Copy the secret to a file
use kubectl apply
kubectl apply -f <file-name.yaml>
Deploy automatically
By Triggering the CI pipeline:
You can push a commit to the ‘main’ branch of the asset-registry repo OR ‘re-run all jobs’ button after selecting an action on the Actions page
How to deploy manually
Spinup a cloud shell after creating a cluster
Download kustomize
This command will download the kustomize executable to the current directory
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
Clone the repo
git clone https://github.com/linux-training-group-1/asset-registry-config.git
Deploy with kubectl apply
./kustomize build asset-registry-config/environments/staging | kubectl apply -f -
Port-forward the mysql service
kubectl port-forward svc/mysql-service 3306:3306 &
This command will run in the background
Add the sql tables and data
wget https://raw.githubusercontent.com/linux-training-group-1/asset-registry/main/scripts/table.sql
wget https://raw.githubusercontent.com/linux-training-group-1/asset-registry/main/scripts/inserts.sql
mysql -h localhost -P 3306 --protocol=tcp -u root --password=password < table.sql
mysql -h localhost -P 3306 --protocol=tcp -u root --password=password < inserts.sql
The table structure and the mysql user for the application is described in table.sql
If the mysql password is incorrect, read the mysql-secret using kubectl get secret mysql-secret -o yaml
and use echo '<password>' | base64 --decode
to decode the root password
Now the staging environment is ready to be used.
Correctly configured staging environment should look like below:
Navigate to the Ingress’s IP address to access the Asset application.