Skip to content

Commit

Permalink
Merge pull request #297 from mbaldessari/quick-fixes
Browse files Browse the repository at this point in the history
Pipeline fixes
  • Loading branch information
mbaldessari authored Nov 13, 2024
2 parents 1f231c8 + 5f58011 commit 9803552
Show file tree
Hide file tree
Showing 20 changed files with 90 additions and 152 deletions.
14 changes: 0 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
NAME=$(shell basename `pwd`)
ARGO_TARGET_NAMESPACE=manuela-ci
PATTERN=industrial-edge
COMPONENT=datacenter
SECRET_NAME="argocd-env"
TARGET_BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
HUBCLUSTER_APPS_DOMAIN=$(shell oc get ingresses.config/cluster -o jsonpath={.spec.domain})
TARGET_ORIGIN ?= origin
Expand All @@ -28,7 +24,6 @@ install: operator-deploy post-install ## installs the pattern, inits the vault a

post-install: ## Post-install tasks
make load-secrets
make argosecret
@echo "Done"

sleep: ## waits for all seed resources to be presents
Expand All @@ -40,15 +35,6 @@ sleep-seed: sleep seed ## waits for seed resources and calls seed-run
seed: sleep ## waits for all seed resources
oc create -f charts/datacenter/pipelines/extra/seed-run.yaml

# Makefiles that use this target must provide:
# PATTERN: The name of the pattern that is using it. This will be used programmatically for the source namespace
# TARGET_NAMESPACE: target namespace to install the secret into
# COMPONENT: The component of the target namespace. In industrial edge, factory or datacenter - and for the secret
# it needs to be datacenter because that's where the CI components run.
# SECRET_NAME: The name of the secret to manage
argosecret: ## creates the argo secret
PATTERN="$(PATTERN)" TARGET_NAMESPACE="$(ARGO_TARGET_NAMESPACE)" COMPONENT="$(COMPONENT)" SECRET_NAME="$(SECRET_NAME)" scripts/secret.sh

build-and-test: ## run a build and test pipeline
oc create -f charts/datacenter/pipelines/extra/build-and-test-run.yaml

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
secretName: argocd-env
- name: github-secret
secret:
secretName: git-repo-credentials
secretName: gitea-admin-secret
- name: build-artifacts
persistentVolumeClaim:
claimName: build-artifacts-rwo
Expand Down
49 changes: 49 additions & 0 deletions charts/datacenter/pipelines/templates/argocd-env-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{ $ns := printf "%s-%s" $.Values.global.pattern $.Values.clusterGroup.name }}
---
apiVersion: external-secrets.io/v1alpha1
kind: PushSecret
metadata:
name: push-secret-ie-namespaced-argocd
namespace: {{ $ns }}
spec:
data:
- conversionStrategy: None
match:
remoteRef:
remoteKey: pushsecrets/namespaced-argo
property: password
secretKey: admin.password
deletionPolicy: Delete
refreshInterval: 10s
secretStoreRefs:
- kind: ClusterSecretStore
name: vault-backend
selector:
secret:
name: {{ $.Values.clusterGroup.name }}-gitops-cluster
updatePolicy: Replace
---
apiVersion: "external-secrets.io/v1beta1"
kind: ExternalSecret
metadata:
name: external-secret-ie-namespaced-argocd
namespace: manuela-ci
spec:
refreshInterval: 15s
secretStoreRef:
name: {{ $.Values.secretStore.name }}
kind: {{ $.Values.secretStore.kind }}
target:
name: argocd-env
template:
type: Opaque
engineVersion: v2
metadata:
data:
ARGOCD_USERNAME: admin
ARGOCD_PASSWORD: "{{ `{{ .argo_admin_password }}` }}"
data:
- secretKey: argo_admin_password
remoteRef:
key: "pushsecrets/namespaced-argo"
property: "password"
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{{- $giturl := coalesce .Values.global.git.hostname (printf "gitea-route-vp-gitea.%s" .Values.global.localClusterDomain) }}
{{- $full_giturl := printf "https://%s/%s/manuela-dev.git" $giturl .Values.global.git.account }}
---
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -7,7 +10,7 @@ data:
IMAGE_PROVIDER: {{ .Values.global.imageregistry.hostname }}
IMAGE_ACCOUNT: {{ .Values.global.imageregistry.account }}
GIT_EMAIL: {{ .Values.global.git.email }}
GIT_DEV_REPO_URL: https://{{ .Values.global.git.hostname }}/{{ .Values.global.git.account }}/manuela-dev.git
GIT_DEV_REPO_URL: {{ $full_giturl }}
GIT_DEV_REPO_REVISION: {{ .Values.global.git.dev_revision }}
GIT_OPS_REPO_TEST_URL: {{ .Values.global.repoURL }}
GIT_OPS_REPO_TEST_REVISION: {{ .Values.global.targetRevision }}
Expand Down
13 changes: 11 additions & 2 deletions charts/datacenter/pipelines/templates/gitea-admin-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# The push secret fetches the randomly generated gitea-admin-secret username+password to vault
# The External Secret will fetch those credentials from vault and place them in the gitea-admin-external-secret
# in the manuela-ci namespace
{{- $giturl := coalesce .Values.global.git.hostname (printf "gitea-route-vp-gitea.%s" .Values.global.localClusterDomain) }}
{{- $full_giturl := printf "https://%s/%s/" $giturl .Values.global.git.account }}

{{- if .Values.clusterGroup.isHubCluster }}
{{- if .Values.global.originURL }}
---
Expand Down Expand Up @@ -47,12 +50,15 @@ spec:
target:
name: gitea-admin-secret
template:
type: Opaque
metadata:
annotations:
# Tekton magic, see https://tekton.dev/vault/pipelines-v0.15.2/auth/
tekton.dev/git-0: {{ $full_giturl }}
type: kubernetes.io/basic-auth
engineVersion: v2
data:
username: "{{ `{{ .gitea_admin_user }}` }}"
password: "{{ `{{ .gitea_admin_password }}` }}"
branch: {{ $.Values.global.targetRevision }}
data:
- secretKey: gitea_admin_user
remoteRef:
Expand All @@ -66,3 +72,6 @@ spec:
{{- end }}{{/* range $i := list manuela-ci ml-development */}}
{{- end }}
{{- end }}

# TODO: We used to have a branch field we need to circle back and expose that differently
# branch:

This file was deleted.

2 changes: 1 addition & 1 deletion charts/datacenter/pipelines/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
name: pipeline
namespace: manuela-ci
secrets:
- name: git-repo-credentials
- name: gitea-admin-secret
{{- if eq .Values.global.imageregistry.type "quay" }}
- name: image-registry-credentials
{{- end }}
4 changes: 2 additions & 2 deletions charts/datacenter/pipelines/templates/tasks/bumpversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
description: the new build version based on the last tags and VERSION file
steps:
- name: current-tag
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.24.3
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.44.5
script: |
VERSION_GLOB="build-$(params.component_name)-$(cat $(params.version_file_path))-*"
Expand Down Expand Up @@ -70,7 +70,7 @@ spec:
name: scratch
workingDir: $(workspaces.gitrepos.path)/$(params.subdirectory)
- name: tag-repo
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.24.3
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.44.5
script: |
VERSION=$(cat /scratch/VERSION)
git tag $VERSION
Expand Down
2 changes: 1 addition & 1 deletion charts/datacenter/pipelines/templates/tasks/cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
# type: string
steps:
- name: cleanup-git-tags
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.24.3
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.44.5
script: |
#list build tags for component in repo
BUILD_TAG_GLOB="build-$(params.COMPONENT_NAME)-*"
Expand Down
2 changes: 1 addition & 1 deletion charts/datacenter/pipelines/templates/tasks/fail.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ metadata:
spec:
steps:
- name: fail
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.24.3
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.44.5
script: |
exit 1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
description: The precise commit SHA that is HEAD of the checked out branch
steps:
- name: checkout
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.24.3
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.44.5
script: |
BRANCH=$(params.BRANCH)
git checkout -q --track -b $BRANCH origin/$BRANCH 2>&1 || git checkout -q -b $BRANCH 2>&1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
- name: sslVerify
description: defines if http.sslVerify should be set to true or false in the global git config
type: string
default: "true"
default: "false"
- name: subdirectory
description: subdirectory inside the "gitrepos" workspace to clone the git repo into
type: string
Expand All @@ -41,7 +41,7 @@ spec:
description: The precise commit SHA that was fetched by this Task
steps:
- name: clone
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.24.3
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.44.5
script: |
CHECKOUT_DIR="$(workspaces.gitrepos.path)/$(params.subdirectory)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
type: string
steps:
- name: commit
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.24.3
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.44.5
script: |
git diff
git config --global user.email "$(cat $(workspaces.config.path)/$(params.GIT_EMAIL_CONFIGMAPKEY))"
Expand Down
12 changes: 9 additions & 3 deletions charts/datacenter/pipelines/templates/tasks/github-push.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{{- $giturl := coalesce .Values.global.git.hostname (printf "gitea-route-vp-gitea.%s" .Values.global.localClusterDomain) }}
{{- $full_giturl := printf "https://%s/%s/manuela-dev.git" $giturl .Values.global.git.account }}
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
Expand All @@ -15,13 +18,16 @@ spec:
description: additional flags for git push
type: string
default: ""
- name: sslVerify
default: "false"
steps:
- name: push
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.24.3
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.44.5
script: |
git remote -v
git branch
git branch -r | grep -q origin/$(git rev-parse --abbrev-ref HEAD) && git pull --ff-only --no-edit
git branch -r | grep -q origin/$(git rev-parse --abbrev-ref HEAD) && git -c http.sslVerify=$(params.sslVerify) pull --ff-only --no-edit
git log -n 2
git push -v $(params.PUSH_FLAGS)
git -c http.sslVerify=$(params.sslVerify) push -v $(params.PUSH_FLAGS)
echo "github push task completed"
workingDir: $(workspaces.gitrepos.path)/$(params.subdirectory)
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ objects:
secretName: argocd-env
- name: github-secret
secret:
secretName: git-repo-credentials
secretName: gitea-admin-secret
- name: gitrepos
volumeClaimTemplate:
spec:
Expand Down
6 changes: 3 additions & 3 deletions charts/datacenter/pipelines/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ imageregistrysecret:
global:
pattern: industrial-edge
repoURL: "https://github.com/pattern-clone/industrial-edge"
localClusterDomain: apps.localcluster.domain
targetRevision: main

git:
hostname: github.com
account: PLAINTEXT
username: PLAINTEXT
#hostname: ""
account: gitea_admin
email: [email protected]
dev_revision: main

Expand Down
71 changes: 0 additions & 71 deletions scripts/secret.sh

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/sleep-seed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ while [ 1 ]; do
echo "Waiting for seed resources to be ready in manuela-ci"
oc get -n manuela-ci pipeline seed 1>/dev/null 2>/dev/null && \
oc get -n manuela-ci task tkn 1>/dev/null 2>/dev/null && \
oc get -n manuela-ci secret git-repo-credentials 1>/dev/null 2>/dev/null && \
oc get -n manuela-ci secret gitea-admin-secret 1>/dev/null 2>/dev/null && \
oc get -n manuela-ci secret image-registry-credentials 1>/dev/null 2>/dev/null && \
echo "Bootstrap seed now running" && break;
sleep 5;
Expand Down
5 changes: 2 additions & 3 deletions values-global.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ global:
installPlanApproval: Automatic

imageregistry:
account: PLAINTEXT
account: rhn_support_mbaldess
hostname: quay.io
type: quay

git:
hostname: github.com
account: PLAINTEXT
account: gitea_admin
#username: PLAINTEXT
email: [email protected]
dev_revision: main
Expand Down
Loading

0 comments on commit 9803552

Please sign in to comment.