Skip to content

Commit

Permalink
adjustments to accommodate publishing to mgmt 24 (#741)
Browse files Browse the repository at this point in the history
* adjustments to accommodate publishing to mgmt 24

* self-peer review

* remove excess ci

* adjust actor

* remove main from trigger

* remove filter for github adjustments

* adjust publish flow

* step name shifts

* chart docs -> kubefirst-docs

* github publish adjustments

* adjustment to trigger ci

* adjusting branches back to main

* lint fixes

* lint fixes

* version changes
  • Loading branch information
johndietz authored Aug 26, 2024
1 parent 5115f59 commit ebc49a9
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 188 deletions.
97 changes: 36 additions & 61 deletions .argo/release.yaml → .argo/publish-and-release.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
namespace: argo
spec:
entrypoint: main
serviceAccountName: argo-server
Expand All @@ -9,7 +11,7 @@ spec:
steps:
- - name: publish-container
templateRef:
name: cwft-kaniko
name: cwft-kaniko-v2
template: build-push
clusterScope: true
arguments:
Expand All @@ -25,7 +27,7 @@ spec:

- - name: checkout
templateRef:
name: cwft-git
name: cwft-git-v2
template: checkout-with-gitops
clusterScope: true
arguments:
Expand All @@ -37,9 +39,9 @@ spec:
- name: gitUrlNoProtocol
value: '{{workflow.parameters.gitUrlNoProtocol}}'

- - name: get-initial-chart-version
- - name: get-initial-micro-chart-version
templateRef:
name: cwft-helm
name: cwft-helm-v2
template: get-chart-version
clusterScope: true
arguments:
Expand All @@ -52,10 +54,10 @@ spec:
- name: chartDir
value: 'charts/{{workflow.parameters.appName}}'

- - name: increment-chart-minor
- - name: set-micro-chart-versions
templateRef:
name: cwft-helm
template: increment-chart-minor
name: cwft-helm-v2
template: set-micro-chart-versions
clusterScope: true
arguments:
artifacts:
Expand All @@ -67,95 +69,63 @@ spec:
- name: chartDir
value: 'charts/{{workflow.parameters.appName}}'
- name: chartVersion
value: '{{steps.get-initial-chart-version.outputs.result}}'

- - name: get-updated-chart-version
templateRef:
name: cwft-helm
template: get-chart-version
clusterScope: true
arguments:
artifacts:
- name: repo-source
from: '{{steps.increment-chart-minor.outputs.artifacts.repo-source}}'
parameters:
- name: appName
value: '{{workflow.parameters.appName}}'
- name: chartDir
value: 'charts/{{workflow.parameters.appName}}'

- - name: set-chart-versions
templateRef:
name: cwft-helm
template: set-chart-versions
clusterScope: true
arguments:
artifacts:
- name: repo-source
from: '{{steps.increment-chart-minor.outputs.artifacts.repo-source}}'
parameters:
- name: appName
value: '{{workflow.parameters.appName}}'
- name: chartDir
value: 'charts/{{workflow.parameters.appName}}'
- name: chartVersion
value: '{{steps.get-updated-chart-version.outputs.result}}'
value: '{{steps.get-initial-micro-chart-version.outputs.result}}'
- name: shortSha
value: '{{workflow.parameters.shortSha}}'

- - name: publish-helm-chart
- - name: publish-micro-helm-chart
templateRef:
name: cwft-helm
name: cwft-helm-v2
template: publish-chart
clusterScope: true
arguments:
artifacts:
- name: repo-source
from: '{{steps.set-chart-versions.outputs.artifacts.repo-source}}'
from: '{{steps.set-micro-chart-versions.outputs.artifacts.repo-source}}'
parameters:
- name: appName
value: '{{workflow.parameters.appName}}'
- name: chartDir
value: 'charts/{{workflow.parameters.appName}}'

- - name: commit-chart-increment
- - name: release-and-tag-main-with-notes
templateRef:
name: cwft-git
template: pull-commit-push
name: cwft-git-v2
template: release-and-tag-main-with-notes
clusterScope: true
arguments:
artifacts:
- name: repo-source
from: '{{steps.set-chart-versions.outputs.artifacts.repo-source}}'
from: '{{steps.set-micro-chart-versions.outputs.artifacts.repo-source}}'
parameters:
- name: repoName
- name: orgName
value: 'konstructio'
- name: appName
value: '{{workflow.parameters.appName}}'
- name: gitUrlNoProtocol
value: '{{workflow.parameters.gitUrlNoProtocol}}'
- name: commitMessage
value: "setting {{workflow.parameters.appName}} {{workflow.parameters.environment}} to chart version {{steps.get-updated-chart-version.outputs.result}}"
- name: tagName
value: '{{steps.get-initial-micro-chart-version.outputs.result}}'

- - name: set-environment-version
templateRef:
name: cwft-helm
template: set-environment-version
name: cwft-helm-v2
template: set-environment-version-for-macro-chart
clusterScope: true
arguments:
artifacts:
- name: repo-source
from: '{{steps.set-chart-versions.outputs.artifacts.repo-source}}'
from: '{{steps.set-micro-chart-versions.outputs.artifacts.repo-source}}'
parameters:
- name: fullChartPath
value: 'registry/{{workflow.parameters.clusterName}}/components/{{workflow.parameters.environment}}/{{workflow.parameters.appName}}/Chart.yaml'
value: '{{workflow.parameters.gitopsDestinationFile}}'
- name: chartVersion
value: '{{steps.get-updated-chart-version.outputs.result}}'
value: '{{steps.get-initial-micro-chart-version.outputs.result}}'
- name: environment
value: '{{workflow.parameters.environment}}'

- - name: commit-to-production
- - name: commit-micro-chart-increment
templateRef:
name: cwft-git
template: pull-commit-push
name: cwft-git-v2
template: pull-commit-sign-push
clusterScope: true
arguments:
artifacts:
Expand All @@ -167,4 +137,9 @@ spec:
- name: gitUrlNoProtocol
value: '{{workflow.parameters.gitUrlNoProtocol}}'
- name: commitMessage
value: 'setting {{workflow.parameters.appName}} {{workflow.parameters.environment}} to chart version {{steps.get-updated-chart-version.outputs.result}}'
# Please, be careful updating this message, it must comply with:
# github skip ci rule: https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
# github skip ci rule: https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs
# gitlab skip ci rule: https://devops.stackexchange.com/questions/6809/is-there-a-ci-skip-option-in-gitlab-ci
# in case, the rule is disbaled or don't work this step will create a circular trigger of builds and bumps of version.
value: "[skip ci] [CI SKIP] setting {{workflow.parameters.appName}} {{workflow.parameters.environment}} to chart version '{{steps.get-initial-micro-chart-version.outputs.result}}'\n\nskip-checks:true"
45 changes: 45 additions & 0 deletions .github/workflows/publish-and-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: Publish docs on prod

env:
ARGO_NAMESPACE: argo
ARGO_VERSION: v3.4.1

on:
push:
branches:
- main
paths-ignore:
- '.github/**'
- '.tools/**'
workflow_dispatch:

jobs:
publish_and_release:
runs-on: self-hosted
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: inject slug/short variables
uses: rlespinasse/github-slug-action@v4
- name: Deploy docs on production
run: |
echo "Install argo"
# Download the binary
curl -sLO https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-amd64.gz
# Unzip
gunzip argo-linux-amd64.gz
# Make binary executable
chmod +x argo-linux-amd64
echo "commit sha ${GITHUB_SHA}"
./argo-linux-amd64 version --short
./argo-linux-amd64 submit .argo/publish-and-release.yaml \
--generate-name="${GITHUB_REPOSITORY_NAME_PART}-publish-and-release-${GITHUB_SHA_SHORT}-" \
-p appName="${GITHUB_REPOSITORY_NAME_PART}" \
-p branch="${GITHUB_REF_NAME}" \
-p environment="production" \
-p containerRegistryURL="ghcr.io/konstructio/${GITHUB_REPOSITORY_NAME_PART}:${GITHUB_SHA_SHORT}" \
-p gitUrlNoProtocol="git@github.com:${GITHUB_REPOSITORY_OWNER_PART_SLUG}" \
-p shortSha="${GITHUB_SHA_SHORT}" \
-p gitopsDestinationFile="registry/environments/production/kubefirst-docs.yaml" \
--wait --log
78 changes: 0 additions & 78 deletions .github/workflows/publish.yml

This file was deleted.

15 changes: 0 additions & 15 deletions charts/docs/templates/tests/test-connection.yaml

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions charts/docs/Chart.yaml → charts/kubefirst-docs/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
appVersion: 31a0cb9
description: Kubefirst documentation Helm chart
name: docs
name: kubefirst-docs
type: application
version: 1.144.0
version: 1.145.0
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "docs.fullname" . }})
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "kubefirst-docs.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "docs.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "docs.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "kubefirst-docs.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "kubefirst-docs.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "docs.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "kubefirst-docs.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }}
Loading

0 comments on commit ebc49a9

Please # to comment.