-
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.
policy: add a decapod app for policies
- Loading branch information
sungil
committed
Nov 16, 2023
1 parent
d49835f
commit d51d9ab
Showing
3 changed files
with
123 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: WorkflowTemplate | ||
metadata: | ||
name: tks-policy | ||
namespace: argo | ||
spec: | ||
entrypoint: deploy | ||
arguments: | ||
parameters: | ||
- name: site_name | ||
value: "coyar0qx1" | ||
- name: revision | ||
value: "main" | ||
- name: app_prefix | ||
value: "{{workflow.parameters.site_name}}" | ||
- name: cluster_id | ||
value: "{{workflow.parameters.site_name}}" | ||
|
||
templates: | ||
- name: deploy | ||
inputs: | ||
parameters: | ||
- name: cluster_id | ||
value: '{{inputs.parameters.cluster_id}}' | ||
- name: appname | ||
value: 'policy-resources' | ||
steps: | ||
- - name: createNamespace | ||
template: createNamespace | ||
arguments: | ||
parameters: | ||
- name: target_namespace | ||
value: gatekeeper-system | ||
- - name: deploy-policy-operator | ||
templateRef: | ||
name: create-application | ||
template: installApps | ||
arguments: | ||
parameters: | ||
- name: list | ||
value: | | ||
[ | ||
{ "app_group": "policy", "path": "opa-gatekeeper", "namespace": "gatekeeper-system", "target_cluster": "" } | ||
] | ||
- - name: deploy-default-policy-resources | ||
templateRef: | ||
name: create-application | ||
template: installApps | ||
arguments: | ||
parameters: | ||
- name: list | ||
value: | | ||
[ | ||
{ "app_group": "policy", "path": "policy-resources", "namespace": "gatekeeper-system", "target_cluster": "" } | ||
] | ||
- - name: argocd-sync-wait | ||
templateRef: | ||
name: create-application | ||
template: argocd-sync-wait | ||
arguments: | ||
parameters: | ||
- name: cluster_id | ||
value: '{{inputs.parameters.cluster_id}}' | ||
- name: appname | ||
value: 'policy-resources' | ||
|
||
- name: createNamespace | ||
inputs: | ||
parameters: | ||
- name: target_namespace | ||
container: | ||
name: create-namespace | ||
image: harbor.taco-cat.xyz/tks/hyperkube:v1.18.6 | ||
command: | ||
- /bin/bash | ||
- '-c' | ||
- | | ||
function log() { | ||
level=$1 | ||
msg=$2 | ||
date=$(date '+%F %H:%M:%S') | ||
echo "[$date] $level $msg" | ||
} | ||
kube_secret=$(kubectl get secret -n {{workflow.parameters.cluster_id}} {{workflow.parameters.cluster_id}}-tks-kubeconfig -o jsonpath="{.data.value}" | base64 -d) | ||
echo -e "kube_secret:\n$kube_secret" | head -n 5 | ||
cat <<< "$kube_secret" > /etc/kubeconfig | ||
kubectl --kubeconfig=/etc/kubeconfig get ns ${TARGET_NAMESPACE} | ||
if [[ $? =~ 1 ]]; then | ||
kubectl --kubeconfig=/etc/kubeconfig create ns ${TARGET_NAMESPACE} | ||
kubectl --kubeconfig=/etc/kubeconfig label ns ${TARGET_NAMESPACE} name=${TARGET_NAMESPACE} | ||
kubectl --kubeconfig=/etc/kubeconfig label ns ${TARGET_NAMESPACE} taco-tls=enabled | ||
log "INFO" "${TARGET_NAMESPACE} successfully created." | ||
fi | ||
env: | ||
- name: TARGET_NAMESPACE | ||
value: '{{inputs.parameters.target_namespace}}' | ||
activeDeadlineSeconds: 900 | ||
retryStrategy: | ||
limit: 2 |
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