diff --git a/.flux.yml b/.flux.yml new file mode 100644 index 000000000..4fd49e18c --- /dev/null +++ b/.flux.yml @@ -0,0 +1,5 @@ +version: 1 +patchUpdated: + generators: + - command: kubectl kustomize . + patchFile: flux-patch.yaml diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index c3e5d3176..646fae392 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -23,6 +23,6 @@ jobs: - name: Build & Push Image run: | cd ./python - echo "${{ secrets.DOCKERPW }}" | docker login -u "[your dockerhub login here]" --password-stdin - docker image build -t [your dockerhub username here]/gitops:hellov1.0 . - docker push [your docker hub username here]/gitops:hellov1.0 + echo "${{ secrets.DOCKERPW }}" | docker login -u manojkumarkudla --password-stdin + docker image build -t manojkumarkudla/gitops:hellov1.3 . + docker push manojkumarkudla/gitops:hellov1.3 diff --git a/base/deployment.yml b/base/deployment.yml new file mode 100644 index 000000000..cd7711cc6 --- /dev/null +++ b/base/deployment.yml @@ -0,0 +1,24 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: helloworld + labels: + app: helloworld +spec: + revisionHistoryLimit: 2 + selector: + matchLabels: + app: helloworld + template: + metadata: + labels: + app: helloworld + spec: + containers: + - name: helloworld + image: manojkumarkudla/gitops:nginx1.0 + imagePullPolicy: Always + ports: + - name: web + containerPort: 80 diff --git a/base/hpa.yml b/base/hpa.yml new file mode 100644 index 000000000..d00c8a8be --- /dev/null +++ b/base/hpa.yml @@ -0,0 +1,16 @@ +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: helloworld +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: helloworld + minReplicas: 1 + maxReplicas: 2 + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: 60 diff --git a/base/kustomization.yml b/base/kustomization.yml new file mode 100644 index 000000000..3449cf1cf --- /dev/null +++ b/base/kustomization.yml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- namespace.yml +- deployment.yml +- service.yml +- hpa.yml diff --git a/base/service.yml b/base/service.yml new file mode 100644 index 000000000..0b5d0dbf1 --- /dev/null +++ b/base/service.yml @@ -0,0 +1,11 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: helloworld +spec: + ports: + - port: 80 + selector: + app: helloworld + type: NodePort diff --git a/docs/Commands.md b/docs/Commands.md index 18aa30a2f..e54ff6893 100644 --- a/docs/Commands.md +++ b/docs/Commands.md @@ -35,6 +35,7 @@ $ kubectl create namespace flux The following is the fluxctl install command used to deploy the flux pods to a cluster within the flux namespace. This is the example used in the "Installing with GitHub Lab". +export GHUSER=your github username ``` $ fluxctl install \ --git-user=${GHUSER} \ diff --git a/namespaces/lasample.yaml b/namespaces/lasample.yaml index 4ddb88401..20835aeba 100644 --- a/namespaces/lasample.yaml +++ b/namespaces/lasample.yaml @@ -2,5 +2,5 @@ apiVersion: v1 kind: Namespace metadata: labels: - name: lasample - name: lasample + name: preprod + name: preprod diff --git a/preprod/flux-patch.yaml b/preprod/flux-patch.yaml new file mode 100644 index 000000000..45e13dfc1 --- /dev/null +++ b/preprod/flux-patch.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + flux.weave.works/automated: "true" + flux.weave.works/tag.helloworld: semver:~1 + name: preprod-helloworld + namespace: preprod +spec: + template: + spec: + $setElementOrder/containers: + - name: helloworld + containers: + - image: particule/helloworld:1.1 + name: helloworld diff --git a/preprod/kustomization.yml b/preprod/kustomization.yml new file mode 100644 index 000000000..365e9f2b4 --- /dev/null +++ b/preprod/kustomization.yml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +bases: +- ../base/ +namespace: preprod +namePrefix: preprod- diff --git a/prod/flux-patch.yaml b/prod/flux-patch.yaml new file mode 100644 index 000000000..f43c5188a --- /dev/null +++ b/prod/flux-patch.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + flux.weave.works/locked: "true" + flux.weave.works/locked_msg: Lock deployment in production + flux.weave.works/locked_user: Particule + name: prod-helloworld + namespace: prod diff --git a/prod/kustomization.yml b/prod/kustomization.yml new file mode 100644 index 000000000..358eb53ee --- /dev/null +++ b/prod/kustomization.yml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +bases: +- ../base/ +namespace: prod +namePrefix: prod- +patchesStrategicMerge: +- replicas-patch.yml diff --git a/prod/replicas-patch.yml b/prod/replicas-patch.yml new file mode 100644 index 000000000..877c9ab3c --- /dev/null +++ b/prod/replicas-patch.yml @@ -0,0 +1,8 @@ +--- +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: helloworld +spec: + minReplicas: 2 + maxReplicas: 4 diff --git a/production/deployment.yml b/production/deployment.yml new file mode 100644 index 000000000..85b86d625 --- /dev/null +++ b/production/deployment.yml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello + namespace: lasample + labels: + app: hello +spec: + selector: + matchLabels: + app: hello + template: + metadata: + labels: + app: hello + spec: + containers: + - name: hello + image: manojkumarkudla/gitops:hellov1.1 diff --git a/python/Dockerfile b/python/Dockerfile index f03e5e3f2..ddc1000ad 100644 --- a/python/Dockerfile +++ b/python/Dockerfile @@ -2,4 +2,4 @@ FROM python:3-alpine COPY . /python WORKDIR /python RUN pip install -r requirements.txt -CMD python /python/app.py +CMD ["python", "/python/app.py", "ENV PIP_ROOT_USER_ACTION=ignore"] diff --git a/python/app.py b/python/app.py index 358088e4c..3802dc25d 100644 --- a/python/app.py +++ b/python/app.py @@ -3,7 +3,7 @@ @app.route("/") def hello(): - return "Hello World!" + return "Hello World!1!" if __name__ == "__main__": app.run(host='0.0.0.0', port=8000) diff --git a/qa/deployment.yml b/qa/deployment.yml new file mode 100644 index 000000000..7b9429775 --- /dev/null +++ b/qa/deployment.yml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello + namespace: lasample + labels: + app: hello +spec: + selector: + matchLabels: + app: hello + template: + metadata: + labels: + app: hello + spec: + containers: + - name: hello + image: manojkumarkudla/gitops:hellov1.2 diff --git a/values-flux-preprod.yaml b/values-flux-preprod.yaml new file mode 100644 index 000000000..6e4ff8efd --- /dev/null +++ b/values-flux-preprod.yaml @@ -0,0 +1,12 @@ +git: + pollInterval: 1m + url: git@github.com:manojkumarkudla/content-gitops.git + branch: master + path: preprod +syncGarbageCollection: + enabled: true +manifestGeneration: true +additionalArgs: + - --git-sync-tag=flux-sync-preprod +allowedNamespaces: + - preprod diff --git a/values-flux-prod.yaml b/values-flux-prod.yaml new file mode 100644 index 000000000..2fb9d848b --- /dev/null +++ b/values-flux-prod.yaml @@ -0,0 +1,8 @@ +git: + pollInterval: 1m + url: git@github.com:manojkumarkudla/content-gitops.git + branch: master + path: prod +syncGarbageCollection: + enabled: true +manifestGeneration: true diff --git a/workloads/nginx.yaml b/workloads/nginx.yaml index ddeb6a96c..2af66a3c3 100644 --- a/workloads/nginx.yaml +++ b/workloads/nginx.yaml @@ -6,7 +6,7 @@ metadata: labels: app: nginx spec: - replicas: 2 + #replicas: 2 selector: matchLabels: app: nginx