diff --git a/.devops/k8s/base/deployment.yaml b/.devops/k8s/base/deployment.yaml deleted file mode 100644 index 0fd05ec..0000000 --- a/.devops/k8s/base/deployment.yaml +++ /dev/null @@ -1,50 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: ladesa-ro-docs -spec: - replicas: 1 - selector: - matchLabels: - name: ladesa-ro-docs - strategy: - rollingUpdate: - maxSurge: 1 - maxUnavailable: 0 - template: - metadata: - labels: - name: ladesa-ro-docs - spec: - containers: - - name: ladesa-ro-docs - image: "nginx:1" - imagePullPolicy: Always - ports: - - name: web - containerPort: 80 - readinessProbe: - httpGet: - path: / - port: 80 - initialDelaySeconds: 5 - periodSeconds: 10 - livenessProbe: - httpGet: - path: / - port: 80 - initialDelaySeconds: 10 - periodSeconds: 15 - startupProbe: - httpGet: - path: / - port: 80 - failureThreshold: 30 - periodSeconds: 10 - resources: - requests: - cpu: "50m" - memory: "1Gi" - limits: - memory: "2Gi" - cpu: "2" diff --git a/.devops/k8s/base/kustomization.yaml b/.devops/k8s/base/kustomization.yaml deleted file mode 100644 index 2b82d68..0000000 --- a/.devops/k8s/base/kustomization.yaml +++ /dev/null @@ -1,12 +0,0 @@ -resources: - - deployment.yaml - - service.yaml - -commonLabels: - app: ladesa-ro-docs - -commonAnnotations: - app: ladesa-ro-docs-annotations -# -# namePrefix: ladesa-ro-docs- -# nameSuffix: -v1 diff --git a/.devops/k8s/base/service.yaml b/.devops/k8s/base/service.yaml deleted file mode 100644 index 2e92762..0000000 --- a/.devops/k8s/base/service.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: ladesa-ro-docs - labels: - name: ladesa-ro-docs -spec: - type: NodePort - selector: - name: ladesa-ro-docs - ports: - - name: web - targetPort: web - port: 80 diff --git a/.devops/k8s/overlays/production/config.properties b/.devops/k8s/overlays/production/config.properties deleted file mode 100644 index 190a694..0000000 --- a/.devops/k8s/overlays/production/config.properties +++ /dev/null @@ -1 +0,0 @@ -ENV=prod \ No newline at end of file diff --git a/.devops/k8s/overlays/production/deployment.yaml b/.devops/k8s/overlays/production/deployment.yaml deleted file mode 100644 index 20cc942..0000000 --- a/.devops/k8s/overlays/production/deployment.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: ladesa-ro-docs -spec: - replicas: 1 - template: - spec: - imagePullSecrets: - - name: ladesa-registry-pull-secret - containers: - - name: ladesa-ro-docs - image: "registry.ladesa.com.br/docs:production" diff --git a/.devops/k8s/overlays/production/ingress.yaml b/.devops/k8s/overlays/production/ingress.yaml deleted file mode 100644 index f788572..0000000 --- a/.devops/k8s/overlays/production/ingress.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: ladesa-ro-docs-ingress -spec: - rules: - - host: docs.ladesa.com.br - http: - paths: - - path: / - pathType: ImplementationSpecific - backend: - service: - name: ladesa-ro-docs - port: - name: web diff --git a/.devops/k8s/overlays/production/kustomization.yaml b/.devops/k8s/overlays/production/kustomization.yaml deleted file mode 100644 index 891222f..0000000 --- a/.devops/k8s/overlays/production/kustomization.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -resources: - - ../../base - - ingress.yaml - -namespace: ladesa-ro-production - -patches: - - path: deployment.yaml - -configMapGenerator: - - name: ladesa-ro-docs-configmap - env: config.properties diff --git a/.devops/values.common.yml b/.devops/values.common.yml new file mode 100644 index 0000000..57dc77b --- /dev/null +++ b/.devops/values.common.yml @@ -0,0 +1,42 @@ +applicationName: ladesa-ro-docs + +service: + enabled: true + type: NodePort + ports: + - name: web-service + port: 80 + targetPort: web-port + +deployment: + enabled: false + + replicas: 1 + + containerSecurityContext: false + + ports: + - containerPort: 80 + name: web-port + + readinessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 5 + periodSeconds: 10 + livenessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 10 + periodSeconds: 15 + startupProbe: + httpGet: + path: / + port: 80 + failureThreshold: 30 + periodSeconds: 10 + +ingress: + enabled: false diff --git a/.github/workflows/cd-build-and-push.yml b/.github/workflows/cd-build-and-push.yml deleted file mode 100644 index 5beca97..0000000 --- a/.github/workflows/cd-build-and-push.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: "Continuous Deployment – Job Build and Push" - -on: - workflow_call: - inputs: - setup-qemu: - type: boolean - required: false - default: false - - build-image: - type: boolean - required: false - default: true - - push-image: - type: boolean - required: false - default: true - - image-name: - type: string - required: true - - image-tag: - type: string - required: true - secrets: - push-image-registry-url: - required: false - - push-image-registry-username: - required: false - - push-image-registry-token: - required: false - -# concurrency: -# cancel-in-progress: false -# group: ${{ github.workflow }}-${{ github.ref }} - -jobs: - image-build-push: - runs-on: ubuntu-latest - - permissions: - # packages: write - # attestations: write - # id-token: write - contents: read - - steps: - - name: Set up QEMU - if: ${{ inputs.setup-qemu == true }} - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - # - name: Local build container image - # if: ${{ inputs.build-image == true }} - # uses: docker/build-push-action@v6 - # with: - # push: false - # tags: cr.ladesa.local/docs - # cache-from: type=gha - # cache-to: type=gha,mode=max - - - name: Login into Registry - if: ${{ inputs.push-image == true }} - uses: docker/login-action@v3 - with: - registry: ${{ secrets.push-image-registry-url }} - username: ${{ secrets.push-image-registry-username }} - password: ${{ secrets.push-image-registry-token }} - - - name: Build and push container image to the registry - if: ${{ inputs.build-image == true }} - uses: docker/build-push-action@v6 - with: - push: ${{ inputs.push-image == true }} - tags: ${{ secrets.push-image-registry-url }}/${{ inputs.image-name }}:${{ inputs.image-tag }} - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/.github/workflows/cd-deploy.yml b/.github/workflows/cd-deploy.yml deleted file mode 100644 index 22c9acc..0000000 --- a/.github/workflows/cd-deploy.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: "Continuous Deployment – Job Deploy" - -on: - workflow_call: - -env: - PRODUCTION_URL: https://docs.ladesa.com.br - PRODUCTION_K8S_DEPLOYMENT: ladesa-ro-docs - PRODUCTION_K8S_NAMESPACE: ladesa-ro-production - -jobs: - deploy-production: - name: Deploy to Cluster - - runs-on: deploy - - environment: - name: production - url: ${{ env.PRODUCTION_URL }} - - steps: - - uses: actions/checkout@v4 - - - name: deploy resources to kubernetes cluster - working-directory: ./.devops/k8s/overlays/production - run: | - kubectl kustomize . | envsubst | kubectl apply -f -; - - kubectl rollout restart \ - deployment.apps/${{ env.PRODUCTION_K8S_DEPLOYMENT }} \ - --namespace ${{ env.PRODUCTION_K8S_NAMESPACE }} \ - ; diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index a2a3da0..0fe345f 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -6,21 +6,47 @@ on: branches: - main +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + jobs: - cd-build-push: - name: "CD: Build and Push" - uses: ./.github/workflows/cd-build-and-push.yml - with: - setup-qemu: false - image-name: ${{ vars.IMAGE_NAME }} - image-tag: ${{ vars.IMAGE_TAG }} - secrets: - push-image-registry-url: ${{ secrets.REGISTRY_URL }} - push-image-registry-username: ${{ secrets.REGISTRY_USERNAME }} - push-image-registry-token: ${{ secrets.REGISTRY_TOKEN }} - - cd-deploy: - name: "CD: Deploy" - uses: ./.github/workflows/cd-deploy.yml - secrets: inherit - needs: [cd-build-push] + cd_build_push: + name: "Build and Push" + runs-on: ubuntu-latest + + environment: + name: production + + steps: + - uses: actions/checkout@v4 + + - uses: ladesa-ro/esteira-ci-cd/actions/build-and-push@main + with: + setup-qemu: "false" + build-image: "true" + push-image: "true" + push-image-registry-url: ${{ secrets.REGISTRY_URL }} + push-image-registry-username: ${{ secrets.REGISTRY_USERNAME }} + push-image-registry-token: ${{ secrets.REGISTRY_TOKEN }} + image-tag: ${{ vars.BUILD_IMAGE_TAG }} + image-name: ${{ vars.BUILD_IMAGE_NAME }} + + cd_deploy: + name: Deploy to Cluster + + runs-on: deploy + needs: [cd_build_push] + + environment: + name: production + url: ${{ vars.DEPLOY_URL }} + + steps: + - uses: actions/checkout@v4 + + - uses: ladesa-ro/esteira-ci-cd/actions/deploy-k8s-stakater-application@main + with: + helm-values: ${{ vars.DEPLOY_HELM_VALUES }} + deployment: ${{ vars.K8S_DEPLOYMENT }} + namespace: ${{ vars.K8S_NAMESPACE }}