|
| 1 | +# We copy the vp-private-repo-credentials from the "openshift-gitops" namespace |
| 2 | +# to the "open-cluster-management" via the "private-hub-policy" |
| 3 | +# |
| 4 | +# Then we copy the secret from the "open-cluster-management" namespace to the |
| 5 | +# managed clusters "openshift-gitops" instance |
| 6 | +# |
| 7 | +# And we also copy the same secret to the namespaced argo's namespace |
| 8 | +{{ if $.Values.global.privateRepo }} |
| 9 | +{{ if .Values.clusterGroup.isHubCluster }} |
| 10 | +--- |
| 11 | +apiVersion: policy.open-cluster-management.io/v1 |
| 12 | +kind: Policy |
| 13 | +metadata: |
| 14 | + name: private-hub-policy |
| 15 | + annotations: |
| 16 | + argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true |
| 17 | + argocd.argoproj.io/compare-options: IgnoreExtraneous |
| 18 | +spec: |
| 19 | + remediationAction: enforce |
| 20 | + disabled: false |
| 21 | + policy-templates: |
| 22 | + - objectDefinition: |
| 23 | + apiVersion: policy.open-cluster-management.io/v1 |
| 24 | + kind: ConfigurationPolicy |
| 25 | + metadata: |
| 26 | + name: private-hub-config |
| 27 | + spec: |
| 28 | + remediationAction: enforce |
| 29 | + severity: medium |
| 30 | + namespaceSelector: |
| 31 | + include: |
| 32 | + - default |
| 33 | + object-templates: |
| 34 | + - complianceType: mustonlyhave |
| 35 | + objectDefinition: |
| 36 | + kind: Secret |
| 37 | + apiVersion: v1 |
| 38 | + type: Opaque |
| 39 | + metadata: |
| 40 | + name: vp-private-repo-credentials |
| 41 | + namespace: open-cluster-management |
| 42 | + labels: |
| 43 | + argocd.argoproj.io/secret-type: repository |
| 44 | + data: '{{ `{{copySecretData "openshift-gitops" "vp-private-repo-credentials"}}` }}' |
| 45 | +--- |
| 46 | +apiVersion: policy.open-cluster-management.io/v1 |
| 47 | +kind: PlacementBinding |
| 48 | +metadata: |
| 49 | + name: private-hub-placement-binding |
| 50 | + annotations: |
| 51 | + argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true |
| 52 | +placementRef: |
| 53 | + name: private-hub-placement |
| 54 | + kind: PlacementRule |
| 55 | + apiGroup: apps.open-cluster-management.io |
| 56 | +subjects: |
| 57 | + - name: private-hub-policy |
| 58 | + kind: Policy |
| 59 | + apiGroup: policy.open-cluster-management.io |
| 60 | +--- |
| 61 | +apiVersion: apps.open-cluster-management.io/v1 |
| 62 | +kind: PlacementRule |
| 63 | +metadata: |
| 64 | + name: private-hub-placement |
| 65 | + annotations: |
| 66 | + argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true |
| 67 | +spec: |
| 68 | + clusterConditions: |
| 69 | + - status: 'True' |
| 70 | + type: ManagedClusterConditionAvailable |
| 71 | + clusterSelector: |
| 72 | + matchExpressions: |
| 73 | + - key: local-cluster |
| 74 | + operator: In |
| 75 | + values: |
| 76 | + - 'true' |
| 77 | +--- |
| 78 | +{{ end }}{{- /* if .Values.clusterGroup.isHubCluster */}} |
| 79 | +{{- range .Values.clusterGroup.managedClusterGroups }} |
| 80 | +{{- $group := . }} |
| 81 | +{{- if not .hostedArgoSites }} |
| 82 | +apiVersion: policy.open-cluster-management.io/v1 |
| 83 | +kind: Policy |
| 84 | +metadata: |
| 85 | + name: private-{{ .name }}-policy |
| 86 | + annotations: |
| 87 | + argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true |
| 88 | + argocd.argoproj.io/compare-options: IgnoreExtraneous |
| 89 | +spec: |
| 90 | + remediationAction: enforce |
| 91 | + disabled: false |
| 92 | + policy-templates: |
| 93 | + - objectDefinition: |
| 94 | + apiVersion: policy.open-cluster-management.io/v1 |
| 95 | + kind: ConfigurationPolicy |
| 96 | + metadata: |
| 97 | + name: private-{{ .name }}-config |
| 98 | + spec: |
| 99 | + remediationAction: enforce |
| 100 | + severity: medium |
| 101 | + namespaceSelector: |
| 102 | + include: |
| 103 | + - default |
| 104 | + object-templates: |
| 105 | + - complianceType: mustonlyhave |
| 106 | + objectDefinition: |
| 107 | + kind: Secret |
| 108 | + apiVersion: v1 |
| 109 | + type: Opaque |
| 110 | + metadata: |
| 111 | + name: vp-private-repo-credentials |
| 112 | + namespace: openshift-gitops |
| 113 | + labels: |
| 114 | + argocd.argoproj.io/secret-type: repository |
| 115 | + data: '{{ `{{hub copySecretData "open-cluster-management" "vp-private-repo-credentials" hub}}` }}' |
| 116 | + - complianceType: mustonlyhave |
| 117 | + objectDefinition: |
| 118 | + kind: Secret |
| 119 | + apiVersion: v1 |
| 120 | + type: Opaque |
| 121 | + metadata: |
| 122 | + name: vp-private-repo-credentials |
| 123 | + namespace: {{ $.Values.global.pattern }}-{{ .name }} |
| 124 | + labels: |
| 125 | + argocd.argoproj.io/secret-type: repository |
| 126 | + data: '{{ `{{hub copySecretData "open-cluster-management" "vp-private-repo-credentials" hub}}` }}' |
| 127 | +--- |
| 128 | +apiVersion: policy.open-cluster-management.io/v1 |
| 129 | +kind: PlacementBinding |
| 130 | +metadata: |
| 131 | + name: private-{{ .name }}-placement-binding |
| 132 | + annotations: |
| 133 | + argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true |
| 134 | +placementRef: |
| 135 | + name: private-{{ .name }}-placement |
| 136 | + kind: PlacementRule |
| 137 | + apiGroup: apps.open-cluster-management.io |
| 138 | +subjects: |
| 139 | + - name: private-{{ .name }}-policy |
| 140 | + kind: Policy |
| 141 | + apiGroup: policy.open-cluster-management.io |
| 142 | +--- |
| 143 | +apiVersion: apps.open-cluster-management.io/v1 |
| 144 | +kind: PlacementRule |
| 145 | +metadata: |
| 146 | + name: private-{{ .name }}-placement |
| 147 | + annotations: |
| 148 | + argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true |
| 149 | +spec: |
| 150 | + clusterConditions: |
| 151 | + - status: 'True' |
| 152 | + type: ManagedClusterConditionAvailable |
| 153 | + clusterSelector: |
| 154 | + matchExpressions: |
| 155 | + - key: local-cluster |
| 156 | + operator: NotIn |
| 157 | + values: |
| 158 | + - 'true' |
| 159 | +{{- end }}{{- /* if not .hostedArgoSites */}} |
| 160 | +{{- end }}{{- /* range .Values.clusterGroup.managedClusterGroups */}} |
| 161 | +{{- end }}{{- /* if $.Values.global.privateRepo */}} |
0 commit comments