-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from robertchoi80/main
add sealed-secrets setup workflow
- Loading branch information
Showing
9 changed files
with
251 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Install kubeseal binary | ||
``` | ||
$ wget https://github.com/bitnami-labs/sealed-secrets/releases/download/v0.16.0/kubeseal-linux-amd64 -O kubeseal | ||
$ sudo install -m 755 kubeseal-linux-amd64 /usr/local/bin/kubeseal | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: WorkflowTemplate | ||
metadata: | ||
name: deploy-secrets | ||
namespace: argo | ||
spec: | ||
templates: | ||
- name: deploySecretsToUserCluster | ||
activeDeadlineSeconds: 120 | ||
inputs: | ||
parameters: | ||
- name: repo_url # Eg, "tks-management/011b88fa-4d53-439f-9336-67845f994051/25db54c6-d6cb-459b-9148-1b02ac545753" | ||
- name: secret_path # Eg, "sealed-cert/secret.yaml" | ||
- name: kubeconfig_secret_name # Eg, "25db54c6-d6cb-459b-9148-1b02ac545753-kubeconfig" | ||
container: | ||
image: k8s.gcr.io/hyperkube:v1.18.8 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- /bin/bash | ||
- -c | ||
- | | ||
cat <<< "$KUBE_CONFIG" > /etc/kubeconfig | ||
|
||
git clone https://$(echo -n $gittoken)@$repo_url | ||
repo_name=$(basename $repo_url) | ||
|
||
kubectl apply --kubeconfig=/etc/kubeconfig -f $repo_name/"{{inputs.parameters.secret_path}}" | ||
|
||
# TODO: need to add logic to check if the secret was successfully created? | ||
|
||
envFrom: | ||
- secretRef: | ||
name: "gittoken" | ||
env: | ||
- name: repo_url | ||
value: "{{ inputs.parameters.repo_url }}" | ||
- name: KUBE_CONFIG | ||
valueFrom: | ||
secretKeyRef: | ||
name: "{{ inputs.parameters.kubeconfig_secret_name }}" | ||
key: value | ||
|
||
- name: deploySecretsToAdminCluster | ||
activeDeadlineSeconds: 120 | ||
inputs: | ||
parameters: | ||
- name: repo_url # Eg, "openinfradev/tks-admin-site" | ||
- name: secret_path # Eg, "directory/secret.yaml" | ||
container: | ||
image: k8s.gcr.io/hyperkube:v1.18.8 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- /bin/bash | ||
- -c | ||
- | | ||
git clone https://$(echo -n $gittoken)@$repo_url | ||
repo_name=$(basename $repo_url) | ||
kubectl apply -f $repo_name/"{{inputs.parameters.secret_path}}" | ||
# TODO: need to add logic to check if the secret was successfully created? | ||
env: | ||
- name: repo_url | ||
value: "{{ inputs.parameters.repo_url }}" | ||
envFrom: | ||
- secretRef: | ||
name: "gittoken" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: WorkflowTemplate | ||
metadata: | ||
name: setup-sealed-secrets-on-admincluster | ||
namespace: argo | ||
spec: | ||
entrypoint: process | ||
arguments: | ||
parameters: | ||
# For create-application task # | ||
- name: manifest_repo_url | ||
value: "https://github.com/openinfradev/decapod-manifests" | ||
- name: site_name | ||
value: "hanu-reference" | ||
- name: app_group | ||
value: "sealed-secrets" | ||
- name: revision | ||
value: "main" | ||
## Uncomment following lines and customize to fetch any secrets you want ## | ||
# - name: master_key_repo_url | ||
# value: "github.com/openinfradev/tks-admin-site" | ||
# - name: master_key_secret_name | ||
# value: "github.com/openinfradev/tks-admin-site" | ||
# - name: sealed_secrets_repo_url | ||
# value: "github.com/openinfradev/tks-admin-site" | ||
# ... | ||
########################################################################### | ||
templates: | ||
- name: process | ||
steps: | ||
- - name: deployMasterKey | ||
templateRef: | ||
name: deploy-secrets | ||
template: deploySecretsToAdminCluster | ||
arguments: | ||
parameters: | ||
# In case of user cluster, repo url should be constructed from parameters | ||
# such as git_account, contract id & cluster id. | ||
- name: repo_url | ||
value: "github.com/openinfradev/tks-admin-site" | ||
- name: secret_path | ||
value: "sealed-secret-key/master-key-secret.yaml" | ||
|
||
- - name: installControllers | ||
templateRef: | ||
name: create-application | ||
template: installApps | ||
arguments: | ||
parameters: | ||
- name: list | ||
value: | | ||
[ | ||
{ "path": "sealed-secrets-controller", "namespace": "kube-system" }, | ||
{ "path": "kubed", "namespace": "kube-system" } | ||
] | ||
- - name: deploySealedSecret | ||
templateRef: | ||
name: deploy-secrets | ||
template: deploySecretsToAdminCluster | ||
arguments: | ||
parameters: | ||
- name: repo_url | ||
value: "github.com/openinfradev/tks-admin-site" | ||
- name: secret_path | ||
value: "sealed-certificates/taco-cat-tls-sealed.yaml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: WorkflowTemplate | ||
metadata: | ||
name: setup-sealed-secrets-on-usercluster | ||
namespace: argo | ||
spec: | ||
entrypoint: process | ||
arguments: | ||
parameters: | ||
- name: git_account | ||
value: "tks-management" | ||
- name: contract_id | ||
value: "011b88fa-4d53-439f-9336-67845f994051" | ||
- name: cluster_id | ||
value: "" | ||
- name: app_group | ||
value: "sealed-secrets" | ||
- name: revision | ||
value: "main" | ||
templates: | ||
- name: process | ||
steps: | ||
- - name: deployMasterKey | ||
templateRef: | ||
name: deploy-secrets | ||
template: deploySecretsToUserCluster | ||
arguments: | ||
parameters: | ||
- name: repo_url | ||
value: "github.com/openinfradev/tks-admin-site" | ||
- name: secret_path | ||
value: "sealed-secret-key/master-key-secret.yaml" | ||
- name: kubeconfig_secret_name | ||
value: "{{workflow.parameters.cluster_id}}-kubeconfig" | ||
|
||
- - name: installControllers | ||
templateRef: | ||
name: tks-create-application-new | ||
template: installApps | ||
arguments: | ||
parameters: | ||
- name: list | ||
value: | | ||
[ | ||
{ "path": "sealed-secrets-controller", "namespace": "kube-system" }, | ||
{ "path": "kubed", "namespace": "kube-system" } | ||
] | ||
- - name: deploySealedSecret | ||
templateRef: | ||
name: deploy-secrets | ||
template: deploySecretsToUserCluster | ||
arguments: | ||
parameters: | ||
########################################################################## | ||
# For real use case example | ||
#- name: repo_url | ||
# value: "github.com/tks-management/{{workflow.parameters.contract_id}}" | ||
#- name: secret_path | ||
# value: "sealed-certificates/user-cat-tls-sealed.yaml" | ||
########################################################################## | ||
- name: repo_url | ||
value: "github.com/openinfradev/tks-admin-site" | ||
- name: secret_path | ||
value: "sealed-certificates/taco-cat-tls-sealed.yaml" | ||
- name: kubeconfig_secret_name | ||
value: "{{workflow.parameters.cluster_id}}-kubeconfig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.