Skip to content

Commit 3aa12b5

Browse files
committed
Switch to using "repo secret" method for catalog URL & credentials
Externally managed https catalog secrets must be updated to have label `argocd.argoproj.io/secret-type=repo-creds` and must have `url: <catalog url>` so ArgoCD can match them to the repository secret.
1 parent 2df60c3 commit 3aa12b5

File tree

18 files changed

+116
-61
lines changed

18 files changed

+116
-61
lines changed

component/argocd.jsonnet

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -231,27 +231,6 @@ local argocd(name) =
231231
version: params.images.argocd.tag,
232232
applicationInstanceLabelKey: 'argocd.argoproj.io/instance',
233233
controller: applicationController,
234-
initialRepositories: '- url: ' + inv.parameters.cluster.catalog_url,
235-
repositoryCredentials: if useHttpsCatalog then
236-
|||
237-
- url: %(catalog_url)s
238-
usernameSecret:
239-
name: %(secret)s
240-
key: username
241-
passwordSecret:
242-
name: %(secret)s
243-
key: password
244-
||| % {
245-
catalog_url: inv.parameters.cluster.catalog_url,
246-
secret: params.http_credentials_secret_name,
247-
}
248-
else
249-
|||
250-
- url: ssh://git@
251-
sshPrivateKeySecret:
252-
name: argo-ssh-key
253-
key: sshPrivateKey
254-
|||,
255234
initialSSHKnownHosts: {
256235
keys: |||
257236
bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==
@@ -395,8 +374,35 @@ local argocd(name) =
395374

396375
local ssh_secret = kube._Object('v1', 'Secret', 'argo-ssh-key') {
397376
type: 'Opaque',
398-
};
377+
} + if !useHttpsCatalog then {
378+
metadata+: {
379+
labels+: {
380+
'argocd.argoproj.io/secret-type': 'repo-creds',
381+
},
382+
},
383+
stringData: {
384+
// sshPrivateKey set by Steward -- should be safe with SSA for the ArgoCD
385+
// app. For full safety we should update Steward to use SSA for this
386+
// secret.
387+
url: inv.parameters.cluster.catalog_url,
388+
},
389+
} else {};
399390

391+
local repo_secret = kube._Object('v1', 'Secret', 'cluster-catalog') {
392+
type: 'Opaque',
393+
metadata+: {
394+
labels+: {
395+
'argocd.argoproj.io/secret-type': 'repository',
396+
},
397+
},
398+
stringData: {
399+
type: 'git',
400+
url: inv.parameters.cluster.catalog_url,
401+
// creds always provided in a `repo-creds` secret. Externally managed
402+
// https secrets must be updated to have label
403+
// `argocd.argoproj.io/secret-type=repo-creds`
404+
},
405+
};
400406

401407
// Manually adding certificate for conversion webhook
402408
// as the upstream kustomize is broken.
@@ -511,6 +517,7 @@ local tls_refresh = [
511517
'00_vault_agent_config': vault_agent_config,
512518
'00_kapitan_plugin_config': kapitan_plugin_config,
513519
'00_ssh_secret': ssh_secret,
520+
'00_repo_secret': repo_secret,
514521
'10_argocd': argocd('syn-argocd'),
515522
[if params.network_policies.enabled then '20_networkpolicy']: std.map(function(p) com.namespaced(params.namespace, p), import 'networkpolicy.libsonnet'),
516523
// Manually adding certificate for conversion webhook
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
annotations: {}
5+
labels:
6+
argocd.argoproj.io/secret-type: repository
7+
name: cluster-catalog
8+
name: cluster-catalog
9+
stringData:
10+
type: git
11+
url: ssh://git@git.example.com/org/repo.git
12+
type: Opaque

tests/golden/defaults/argocd/argocd/30_argocd/00_ssh_secret.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ kind: Secret
33
metadata:
44
annotations: {}
55
labels:
6+
argocd.argoproj.io/secret-type: repo-creds
67
name: argo-ssh-key
78
name: argo-ssh-key
9+
stringData:
10+
url: ssh://git@git.example.com/org/repo.git
811
type: Opaque

tests/golden/defaults/argocd/argocd/30_argocd/10_argocd.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ spec:
2727
"operators.coreos.com/Subscription":
2828
"health.lua.useOpenLibs": true
2929
image: quay.io/argoproj/argocd
30-
initialRepositories: '- url: ssh://git@git.example.com/org/repo.git'
3130
initialSSHKnownHosts:
3231
keys: |
3332
bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==
@@ -138,11 +137,6 @@ spec:
138137
- configMap:
139138
name: kapitan-plugin-config
140139
name: kapitan-plugin-config
141-
repositoryCredentials: |
142-
- url: ssh://git@
143-
sshPrivateKeySecret:
144-
name: argo-ssh-key
145-
key: sshPrivateKey
146140
resourceExclusions: |-
147141
- "apiGroups":
148142
- "cilium.io"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
annotations: {}
5+
labels:
6+
argocd.argoproj.io/secret-type: repository
7+
name: cluster-catalog
8+
name: cluster-catalog
9+
stringData:
10+
type: git
11+
url: https://git.example.com/cluster-catalog.git
12+
type: Opaque

tests/golden/https-catalog/argocd/argocd/30_argocd/10_argocd.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ spec:
2727
"operators.coreos.com/Subscription":
2828
"health.lua.useOpenLibs": true
2929
image: quay.io/argoproj/argocd
30-
initialRepositories: '- url: https://git.example.com/cluster-catalog.git'
3130
initialSSHKnownHosts:
3231
keys: |
3332
bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==
@@ -138,14 +137,6 @@ spec:
138137
- configMap:
139138
name: kapitan-plugin-config
140139
name: kapitan-plugin-config
141-
repositoryCredentials: |
142-
- url: https://git.example.com/cluster-catalog.git
143-
usernameSecret:
144-
name: catalog-http-credentials
145-
key: username
146-
passwordSecret:
147-
name: catalog-http-credentials
148-
key: password
149140
resourceExclusions: |-
150141
- "apiGroups":
151142
- "cilium.io"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
annotations: {}
5+
labels:
6+
argocd.argoproj.io/secret-type: repository
7+
name: cluster-catalog
8+
name: cluster-catalog
9+
stringData:
10+
type: git
11+
url: ssh://git@git.example.com/org/repo.git
12+
type: Opaque

tests/golden/openshift/argocd/argocd/30_argocd/00_ssh_secret.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ kind: Secret
33
metadata:
44
annotations: {}
55
labels:
6+
argocd.argoproj.io/secret-type: repo-creds
67
name: argo-ssh-key
78
name: argo-ssh-key
9+
stringData:
10+
url: ssh://git@git.example.com/org/repo.git
811
type: Opaque

tests/golden/openshift/argocd/argocd/30_argocd/10_argocd.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ spec:
2727
"operators.coreos.com/Subscription":
2828
"health.lua.useOpenLibs": true
2929
image: quay.io/argoproj/argocd
30-
initialRepositories: '- url: ssh://git@git.example.com/org/repo.git'
3130
initialSSHKnownHosts:
3231
keys: |
3332
bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==
@@ -141,11 +140,6 @@ spec:
141140
- configMap:
142141
name: kapitan-plugin-config
143142
name: kapitan-plugin-config
144-
repositoryCredentials: |
145-
- url: ssh://git@
146-
sshPrivateKeySecret:
147-
name: argo-ssh-key
148-
key: sshPrivateKey
149143
resourceExclusions: |-
150144
- "apiGroups":
151145
- "cilium.io"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
annotations: {}
5+
labels:
6+
argocd.argoproj.io/secret-type: repository
7+
name: cluster-catalog
8+
name: cluster-catalog
9+
stringData:
10+
type: git
11+
url: ssh://git@git.example.com/org/repo.git
12+
type: Opaque

0 commit comments

Comments
 (0)