Skip to content

Commit

Permalink
Split secret configuration. Migrate from deprecated fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rnc committed Nov 10, 2023
1 parent 98b313a commit e3bf699
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 78 deletions.
22 changes: 3 additions & 19 deletions deploy/base-development.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,16 @@ DIR=`dirname $0`
kubectl apply -f $DIR/namespace.yaml
kubectl config set-context --current --namespace=test-jvm-namespace
kubectl delete --ignore-not-found secret jvm-build-image-secrets jvm-build-git-secrets jvm-build-maven-repo-secrets jvm-build-maven-repo-aws-secrets jvm-build-s3-secrets jvm-build-git-repo-secrets
$DIR/secrets.sh

if [ -n "$QUAY_ORG" ] && [ -n "$QUAY_TOKEN" ]; then
kubectl delete --ignore-not-found secret -n image-controller quaytoken
kubectl create secret generic -n image-controller quaytoken --from-literal "quaytoken=$QUAY_TOKEN" --from-literal "organization=$QUAY_ORG"
fi
kubectl create secret generic jvm-build-image-secrets --from-file=.dockerconfigjson=$HOME/.docker/config.json --type=kubernetes.io/dockerconfigjson
kubectl create secret generic jvm-build-git-secrets --from-literal .git-credentials="
https://$GITHUB_E2E_ORGANIZATION:$GITHUB_TOKEN@github.com
https://test:[email protected]
"
if [ -n "$GIT_DEPLOY_TOKEN" ]; then
kubectl create secret generic jvm-build-git-repo-secrets --from-literal gitdeploytoken="$GIT_DEPLOY_TOKEN"
fi
if [ -n "$MAVEN_PASSWORD" ]; then
kubectl create secret generic jvm-build-maven-repo-secrets --from-literal mavenpassword="$MAVEN_PASSWORD"
fi
if [ -n "$AWS_ACCESS_KEY_ID" ] && [ -n "$AWS_SECRET_ACCESS_KEY" ]; then
if [ -n "$AWS_PROFILE" ]; then
PROFILE="--from-literal awsprofile=$AWS_PROFILE"
fi
kubectl create secret generic jvm-build-maven-repo-aws-secrets --from-literal=awsaccesskey=$AWS_ACCESS_KEY_ID --from-literal awssecretkey="$AWS_SECRET_ACCESS_KEY" $PROFILE
kubectl create secret generic jvm-build-s3-secrets --from-literal=awsaccesskey=$AWS_ACCESS_KEY_ID --from-literal awssecretkey="$AWS_SECRET_ACCESS_KEY" --from-literal awsregion=us-east-1

fi
echo -e "\033[0;32mPatching...\033[0m"
JVM_BUILD_SERVICE_IMAGE=quay.io/$QUAY_USERNAME/hacbs-jvm-controller \
JVM_BUILD_SERVICE_CACHE_IMAGE=quay.io/$QUAY_USERNAME/hacbs-jvm-cache \
JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE=quay.io/$QUAY_USERNAME/hacbs-jvm-build-request-processor:dev \
$DIR/patch-yaml.sh
echo -e "\033[0;32mRunning kubectl...\033[0m"
kubectl apply -k $DIR/overlays/development
15 changes: 9 additions & 6 deletions deploy/operator/config/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

commonLabels:
app: hacbs-jvm-operator
resources:
- system-config.yaml
- system-config.yaml

patchesStrategicMerge:
#note that when updating the ref here you must also update system-config.yaml
- https://raw.githubusercontent.com/redhat-appstudio/jvm-build-service-builder-images/bd8e505b3082a03c030b36868a3753df9db15f97/image-config.yaml
labels:
- includeSelectors: true
pairs:
app: hacbs-jvm-operator

#note that when updating the ref here you must also update system-config.yaml
patches:
- path: https://raw.githubusercontent.com/redhat-appstudio/jvm-build-service-builder-images/bd8e505b3082a03c030b36868a3753df9db15f97/image-config.yaml
46 changes: 22 additions & 24 deletions deploy/operator/overlays/dev-template/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,30 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- servicemonitor.yaml
- servicemonitor_rbac.yaml
- servicemonitor.yaml
- servicemonitor_rbac.yaml
- ../../base

bases:
- "../../base"

images:
- name: hacbs-jvm-operator
newName: jvm-build-service-image
newTag: dev
- name: hacbs-jvm-operator
newName: jvm-build-service-image
newTag: dev

patchesStrategicMerge:
- namespace.yaml
patches:
- patch: |-
- op: replace
path: /spec/template/spec/containers/0/imagePullPolicy
value: Always
target:
kind: Deployment
name: hacbs-jvm-operator

- patch: |-
- op: replace
path: /spec/template/spec/volumes/0/secret/optional
value: true
target:
kind: Deployment
name: hacbs-jvm-operator
patches:
- patch: |-
- op: replace
path: /spec/template/spec/containers/0/imagePullPolicy
value: Always
target:
kind: Deployment
name: hacbs-jvm-operator
- patch: |-
- op: replace
path: /spec/template/spec/volumes/0/secret/optional
value: true
target:
kind: Deployment
name: hacbs-jvm-operator
- path: namespace.yaml
8 changes: 4 additions & 4 deletions deploy/overlays/ci-template/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
- "../../base"

patchesStrategicMerge:
- config.yaml
resources:
- ../../base
patches:
- path: config.yaml
49 changes: 24 additions & 25 deletions deploy/overlays/dev-template/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
- "../../crds/base"
- "../../base"
- "../../operator/config"
- "../../operator/overlays/dev-template"

patches:
- patch: |-
- op: replace
path: /spec/steps/2/image
value: jvm-build-service-reqprocessor-image
target:
kind: Task
name: maven
- patch: |-
- op: add
path: "/spec/template/spec/containers/0/env"
value:
- name: S3_SYNC_ENABLED
value: "true"
target:
kind: Deployment
name: hacbs-jvm-operator
resources:
- ../../crds/base
- ../../base
- ../../operator/config
- ../../operator/overlays/dev-template


patchesStrategicMerge:
- config.yaml
- system-config.yaml
patches:
- patch: |-
- op: replace
path: /spec/steps/2/image
value: jvm-build-service-reqprocessor-image
target:
kind: Task
name: maven
- patch: |-
- op: add
path: "/spec/template/spec/containers/0/env"
value:
- name: S3_SYNC_ENABLED
value: "true"
target:
kind: Deployment
name: hacbs-jvm-operator
- path: config.yaml
- path: system-config.yaml
24 changes: 24 additions & 0 deletions deploy/secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

echo -e "\033[0;32mSecrets...\033[0m"

kubectl config set-context --current --namespace=test-jvm-namespace

kubectl create --dry-run=client -o=yaml secret generic jvm-build-image-secrets --from-file=.dockerconfigjson=$HOME/.docker/config.json --type=kubernetes.io/dockerconfigjson | kubectl apply -f -
kubectl create --dry-run=client -o=yaml secret generic jvm-build-git-secrets --from-literal .git-credentials="
https://$GITHUB_E2E_ORGANIZATION:$GITHUB_TOKEN@github.com
https://test:[email protected]
" | kubectl apply -f -
if [ -n "$GIT_DEPLOY_TOKEN" ]; then
kubectl create --dry-run=client -o=yaml secret generic jvm-build-git-repo-secrets --from-literal gitdeploytoken="$GIT_DEPLOY_TOKEN" | kubectl apply -f -
fi
if [ -n "$MAVEN_PASSWORD" ]; then
kubectl create --dry-run=client -o=yaml secret generic jvm-build-maven-repo-secrets --from-literal mavenpassword="$MAVEN_PASSWORD" | kubectl apply -f -
fi
if [ -n "$AWS_ACCESS_KEY_ID" ] && [ -n "$AWS_SECRET_ACCESS_KEY" ]; then
if [ -n "$AWS_PROFILE" ]; then
PROFILE="--from-literal awsprofile=$AWS_PROFILE"
fi
kubectl create --dry-run=client -o=yaml secret generic jvm-build-maven-repo-aws-secrets --from-literal=awsaccesskey=$AWS_ACCESS_KEY_ID --from-literal awssecretkey="$AWS_SECRET_ACCESS_KEY" $PROFILE | kubectl apply -f -
kubectl create --dry-run=client -o=yaml secret generic jvm-build-s3-secrets --from-literal=awsaccesskey=$AWS_ACCESS_KEY_ID --from-literal awssecretkey="$AWS_SECRET_ACCESS_KEY" --from-literal awsregion=us-east-1 | kubectl apply -f -
fi

0 comments on commit e3bf699

Please sign in to comment.