-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tls cert mount appset controller #985
Changes from 5 commits
7939409
5d68243
2f19674
7cab369
5653cf5
98934b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,11 @@ func getArgoApplicationSetCommand(cr *argoproj.ArgoCD) []string { | |
cmd = append(cmd, "--loglevel") | ||
cmd = append(cmd, getLogLevel(cr.Spec.ApplicationSet.LogLevel)) | ||
|
||
if cr.Spec.ApplicationSet.SCMRootCAPath != "" { | ||
cmd = append(cmd, "--scm-root-ca-path") | ||
cmd = append(cmd, cr.Spec.ApplicationSet.SCMRootCAPath) | ||
} | ||
|
||
// ApplicationSet command arguments provided by the user | ||
extraArgs := cr.Spec.ApplicationSet.ExtraCommandArgs | ||
err := isMergable(extraArgs, cmd) | ||
|
@@ -144,9 +149,26 @@ func (r *ReconcileArgoCD) reconcileApplicationSetDeployment(cr *argoproj.ArgoCD, | |
}, | ||
}, | ||
} | ||
addSCMGitlabVolumeMount := false | ||
if cr.Spec.ApplicationSet.SCMRootCAPath != "" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why should we get the CA mount path from the user, if the operator is going to mount it from a well defined CM. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The alternate approach, would be similar to how TLS certs are handled in ArgoCD Server.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We would not want to create an empty CM as the requests for Gitlab client would use these certs only if the parameter I do like the thought of hard-coding the path of the cert, but I am wondering if there would be any use case where user would want to specify the path. I am open to hard-coding the path for volume mount. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case can we check for the existence of a config map with name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we can do that. I will update the code. Do you have a path in mind? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The one you had suggested in the example, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated to use |
||
cm := newConfigMapWithName(getCAConfigMapName(cr), cr) | ||
if argoutil.IsObjectFound(r.Client, cr.Namespace, common.ArgoCDAppSetGitlabSCMTLSCertsConfigMapName, cm) { | ||
addSCMGitlabVolumeMount = true | ||
podSpec.Volumes = append(podSpec.Volumes, corev1.Volume{ | ||
Name: "appset-gitlab-scm-tls-cert", | ||
VolumeSource: corev1.VolumeSource{ | ||
ConfigMap: &corev1.ConfigMapVolumeSource{ | ||
LocalObjectReference: corev1.LocalObjectReference{ | ||
Name: common.ArgoCDAppSetGitlabSCMTLSCertsConfigMapName, | ||
}, | ||
}, | ||
}, | ||
}) | ||
} | ||
} | ||
|
||
podSpec.Containers = []corev1.Container{ | ||
applicationSetContainer(cr), | ||
applicationSetContainer(cr, addSCMGitlabVolumeMount), | ||
} | ||
AddSeccompProfileForOpenShift(r.Client, podSpec) | ||
|
||
|
@@ -185,7 +207,7 @@ func (r *ReconcileArgoCD) reconcileApplicationSetDeployment(cr *argoproj.ArgoCD, | |
|
||
} | ||
|
||
func applicationSetContainer(cr *argoproj.ArgoCD) corev1.Container { | ||
func applicationSetContainer(cr *argoproj.ArgoCD, addSCMGitlabVolumeMount bool) corev1.Container { | ||
// Global proxy env vars go first | ||
appSetEnv := []corev1.EnvVar{{ | ||
Name: "NAMESPACE", | ||
|
@@ -202,7 +224,7 @@ func applicationSetContainer(cr *argoproj.ArgoCD) corev1.Container { | |
// Environment specified in the CR take precedence over everything else | ||
appSetEnv = argoutil.EnvMerge(appSetEnv, proxyEnvVars(), false) | ||
|
||
return corev1.Container{ | ||
container := corev1.Container{ | ||
Command: getArgoApplicationSetCommand(cr), | ||
Env: appSetEnv, | ||
Image: getApplicationSetContainerImage(cr), | ||
|
@@ -252,6 +274,13 @@ func applicationSetContainer(cr *argoproj.ArgoCD) corev1.Container { | |
RunAsNonRoot: boolPtr(true), | ||
}, | ||
} | ||
if addSCMGitlabVolumeMount { | ||
container.VolumeMounts = append(container.VolumeMounts, corev1.VolumeMount{ | ||
Name: "appset-gitlab-scm-tls-cert", | ||
MountPath: cr.Spec.ApplicationSet.SCMRootCAPath, | ||
}) | ||
} | ||
return container | ||
} | ||
|
||
func (r *ReconcileArgoCD) reconcileApplicationSetServiceAccount(cr *argoproj.ArgoCD) (*corev1.ServiceAccount, error) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,7 @@ Resources | [Empty] | The container compute resources. | |
LogLevel | info | The log level to be used by the ArgoCD Application Controller component. Valid options are debug, info, error, and warn. | ||
LogFormat | text | The log format to be used by the ArgoCD Application Controller component. Valid options are text or json. | ||
ParallelismLimit | 10 | The kubectl parallelism limit to set for the controller (`--kubectl-parallelism-limit` flag) | ||
SCMRootCaPath (#add-tls-certificate-for-gitlab-scm-provider-to-applicationsets-controller) | [Empty] | The path where the Gitlab SCM Provider's TLS certificate is mounted on the ApplicationSet Controller. The TLS certificate is picked from a configMap `"argocd-appset-gitlab-scm-tls-certs-cm"` and mounted on the applicationset-controller as a volume mount. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct name to |
||
|
||
### ApplicationSet Controller Example | ||
|
||
|
@@ -119,6 +120,24 @@ spec: | |
- bar | ||
``` | ||
|
||
### Add Self signed TLS Certificate for Gitlab SCM Provider to ApplicationSets Controller | ||
|
||
ApplicationSetController added a new option `--scm-root-ca-path` and expects the self-signed TLS certificate to be mounted on the path specified and to be used for Gitlab SCM Provider and Gitlab Pull Request Provider. To set this option, you can set `spec.applicationSet.scmRootCaPath` in ArgoCD CR. The operator expects the TLS certificate to be stored in a ConfigMap named `argocd-appset-gitlab-scm-tls-certs-cm`. When the parameter `spec.applicationSet.scmRootCaPath` is set in ArgoCD CR, the operator checks for ConfigMap named `argocd-appset-gitlab-scm-tls-certs-cm` in the same namespace as the ArgoCD instance and mounts the Certificate stored in ConfigMap to ApplicationSet Controller pods at the path specified by `spec.applicationSet.scmRootCaPath`. | ||
|
||
Below example shows how a user can add scmRootCaPath to the ApplicationSet controller. | ||
```yaml | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: ArgoCD | ||
metadata: | ||
name: example-argocd | ||
labels: | ||
example: applicationset | ||
spec: | ||
applicationSet: | ||
scmRootCaPath: /path/for/tls/certificate/mount | ||
``` | ||
|
||
|
||
## Config Management Plugins | ||
|
||
Configuration to add a config management plugin. This property maps directly to the `configManagementPlugins` field in the `argocd-cm` ConfigMap. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
timeout: 120 | ||
--- | ||
apiVersion: argoproj.io/v1beta1 | ||
kind: ArgoCD | ||
metadata: | ||
name: argocd | ||
namespace: test-1-32-appsets-scm-tls-mount | ||
spec: | ||
applicationSet: | ||
scmRootCaPath: /app/tls/cert | ||
status: | ||
phase: Available | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: argocd-applicationset-controller | ||
namespace: test-1-32-appsets-scm-tls-mount | ||
labels: | ||
app.kubernetes.io/component: controller | ||
app.kubernetes.io/managed-by: argocd | ||
app.kubernetes.io/name: argocd-applicationset-controller | ||
app.kubernetes.io/part-of: argocd-applicationset | ||
spec: | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: argocd-applicationset-controller | ||
template: | ||
spec: | ||
containers: | ||
- command: | ||
- entrypoint.sh | ||
- argocd-applicationset-controller | ||
- --argocd-repo-server | ||
- argocd-repo-server.test-1-32-appsets-scm-tls-mount.svc.cluster.local:8081 | ||
- --loglevel | ||
- info | ||
- --scm-root-ca-path | ||
- /app/tls/cert | ||
volumeMounts: | ||
- mountPath: /app/config/ssh | ||
name: ssh-known-hosts | ||
- mountPath: /app/config/tls | ||
name: tls-certs | ||
- mountPath: /app/config/gpg/source | ||
name: gpg-keys | ||
- mountPath: /app/config/gpg/keys | ||
name: gpg-keyring | ||
- mountPath: /tmp | ||
name: tmp | ||
- mountPath: /app/tls/cert | ||
name: appset-gitlab-scm-tls-cert | ||
volumes: | ||
- configMap: | ||
defaultMode: 420 | ||
name: argocd-ssh-known-hosts-cm | ||
name: ssh-known-hosts | ||
- configMap: | ||
defaultMode: 420 | ||
name: argocd-tls-certs-cm | ||
name: tls-certs | ||
- configMap: | ||
defaultMode: 420 | ||
name: argocd-gpg-keys-cm | ||
name: gpg-keys | ||
- emptyDir: {} | ||
name: gpg-keyring | ||
- emptyDir: {} | ||
name: tmp | ||
- configMap: | ||
defaultMode: 420 | ||
name: argocd-appset-gitlab-scm-tls-certs-cm | ||
name: appset-gitlab-scm-tls-cert |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason for going with config map and not a secret ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No specific reason, followed what we have used for TLS certs.