Skip to content

Commit

Permalink
Merge pull request #353 from openinfradev/policy-serving
Browse files Browse the repository at this point in the history
policy: bugfix to find the policy namespace with the organization
  • Loading branch information
ktkfree authored Apr 17, 2024
2 parents 930c0d7 + 40c24ee commit 6fe4ba9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions deploy_apps/tks-policy-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ spec:
- name: contract_id
- name: cluster_id
container:
name: create-namespace
name: createClusterCR
image: harbor.taco-cat.xyz/tks/hyperkube:v1.18.6
command:
- /bin/bash
Expand All @@ -134,7 +134,7 @@ spec:
exit -1
fi
kube_secret=$(kubectl get secret -n ${CLUSTER_ID} ${CLUSTER_ID}-tks-kubeconfig -o jsonpath="{.data.value}" | base64 -d)
POLICY_NS=$(kubectl get ns ${CLUSTER_ID} -o jsonpath='{.metadata.labels.tks\.io\/primary}')
POLICY_NS=$(kubectl get ns ${CLUSTER_ID} -o jsonpath='{.metadata.labels.tks\.io\/policy}')
cat <<EOF >/tks_cluster_${CLUSTER_ID}.yaml
---
Expand Down
5 changes: 2 additions & 3 deletions tks-cluster/create-usercluster-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,11 @@ spec:
export KUBECONFIG=kubeconfig_adm
####### add tks info. on namespace ########
POLICY_NS=$(kubectl get ns -l tks.io/organization=${CONTRACT_ID} --ignore-not-found=true | grep -v NAME | awk '{print $1}' )
kubectl label ns ${CLUSTER_ID} tks.io/organization=${CONTRACT_ID}
if [ -z "$POLICY_NS" ]; then
if [ $(kubectl get ns -l tks.io/organization=${CONTRACT_ID} -l tks.io/policy --ignore-not-found=true | grep -v NAME | awk '{print $1}' | wc -l ) -eq 0 ]; then
kubectl label ns ${CLUSTER_ID} tks.io/policy=${CLUSTER_ID}
else
kubectl label ns ${CLUSTER_ID} tks.io/policy=${POLICY_NS}
kubectl label ns ${CLUSTER_ID} tks.io/policy=$(kubectl get ns $(kubectl get ns -l tks.io/organization=${CONTRACT_ID} -l tks.io/policy --ignore-not-found=true | grep -v NAME | awk '{print $1}' | head -n 1 ) --ignore-not-found=true -o jsonpath='{.metadata.labels.tks\.io\/policy}' )
fi
###########################################
Expand Down

0 comments on commit 6fe4ba9

Please sign in to comment.