I have a Github repo with 2 branches on it,
main. The first is the "test" environment and the other is the "production" environment. I am working with Google Kubernetes Engine and I have automated deployment from the push on Github to the deploy on GKE. So our workflow is :
- Write code and test locally
- When everything is fine locally, push on
develop(it will automatically deploy on GKE workload
- QA tests on
- If QA tests passed, we create a pull request to put
- Automatically deploy on GKE workload
The deployment of the container is defined in
Dockerfile and the Kubernetes deployment is defined in
kubernetes/app.yaml. Those two files are tracked with Git inside the repo.
The problem here is when we create a pull request to put
main, it also take the two files
main. We end up with the settings from
main, and it messes the whole thing.
I can’t define env variables in those files because it could end up in the wrong branch.
My question is : How can I exclude those files from the pull request ? Or is there any way to manage multiples environment without having to manually modify the files after each pull request ?
I don’t know if it can hlphere is my Dockerfile :
FROM python:3.8 RUN apt-get update && apt-get install -y --no-install-recommends RUN python -m pip install --upgrade pip WORKDIR /app/ COPY requirements.txt . RUN python -m pip install -r requirements.txt COPY . . EXPOSE 8080 CMD ["gunicorn", "-b", ":8080", "main:app"]
And here is my YAML file to deploy on GKE (actually I took the one advised by GKE when creating automated deployment) :
apiVersion: apps/v1 kind: Deployment metadata: labels: app: app_name-api name: app_name-api namespace: default spec: replicas: 1 selector: matchLabels: app: app_name-api strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: app: app_name-api spec: containers: - image: gcr.io/path_to_image/github.com/company_name/app_name imagePullPolicy: IfNotPresent name: app_name-1 --- apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler metadata: labels: app: app_name-api name: app_name-api-pod-autoscaler namespace: default spec: maxReplicas: 3 metrics: - resource: name: cpu targetAverageUtilization: 80 type: Resource minReplicas: 1 scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: app_name-api
Thanks a lot for any help you could provide !
Source: Docker Questions