mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-15 06:26:57 +00:00
Azure Key Vault integration to resolve secrets (#4090)
This commit is contained in:
@@ -7863,6 +7863,53 @@ spec:
|
||||
- containers
|
||||
type: object
|
||||
type: object
|
||||
vaultConfig:
|
||||
properties:
|
||||
azureKeyVault:
|
||||
properties:
|
||||
certificatePath:
|
||||
type: string
|
||||
clientId:
|
||||
type: string
|
||||
tenantId:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
required:
|
||||
- certificatePath
|
||||
- clientId
|
||||
- tenantId
|
||||
- url
|
||||
type: object
|
||||
proxy:
|
||||
properties:
|
||||
http:
|
||||
properties:
|
||||
credentialSecretRef:
|
||||
type: string
|
||||
url:
|
||||
description: Required
|
||||
type: string
|
||||
type: object
|
||||
https:
|
||||
properties:
|
||||
credentialSecretRef:
|
||||
type: string
|
||||
url:
|
||||
description: Required
|
||||
type: string
|
||||
type: object
|
||||
noProxy:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
type:
|
||||
description: |-
|
||||
VaultType represents the type of vault that can be used in the application.
|
||||
It is used to identify which vault integration should be used to resolve secrets.
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
status:
|
||||
description: AutoscalingListenerStatus defines the observed state of AutoscalingListener
|
||||
|
||||
@@ -15504,6 +15504,53 @@ spec:
|
||||
- containers
|
||||
type: object
|
||||
type: object
|
||||
vaultConfig:
|
||||
properties:
|
||||
azureKeyVault:
|
||||
properties:
|
||||
certificatePath:
|
||||
type: string
|
||||
clientId:
|
||||
type: string
|
||||
tenantId:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
required:
|
||||
- certificatePath
|
||||
- clientId
|
||||
- tenantId
|
||||
- url
|
||||
type: object
|
||||
proxy:
|
||||
properties:
|
||||
http:
|
||||
properties:
|
||||
credentialSecretRef:
|
||||
type: string
|
||||
url:
|
||||
description: Required
|
||||
type: string
|
||||
type: object
|
||||
https:
|
||||
properties:
|
||||
credentialSecretRef:
|
||||
type: string
|
||||
url:
|
||||
description: Required
|
||||
type: string
|
||||
type: object
|
||||
noProxy:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
type:
|
||||
description: |-
|
||||
VaultType represents the type of vault that can be used in the application.
|
||||
It is used to identify which vault integration should be used to resolve secrets.
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
status:
|
||||
description: AutoscalingRunnerSetStatus defines the observed state of AutoscalingRunnerSet
|
||||
|
||||
@@ -7784,6 +7784,53 @@ spec:
|
||||
required:
|
||||
- containers
|
||||
type: object
|
||||
vaultConfig:
|
||||
properties:
|
||||
azureKeyVault:
|
||||
properties:
|
||||
certificatePath:
|
||||
type: string
|
||||
clientId:
|
||||
type: string
|
||||
tenantId:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
required:
|
||||
- certificatePath
|
||||
- clientId
|
||||
- tenantId
|
||||
- url
|
||||
type: object
|
||||
proxy:
|
||||
properties:
|
||||
http:
|
||||
properties:
|
||||
credentialSecretRef:
|
||||
type: string
|
||||
url:
|
||||
description: Required
|
||||
type: string
|
||||
type: object
|
||||
https:
|
||||
properties:
|
||||
credentialSecretRef:
|
||||
type: string
|
||||
url:
|
||||
description: Required
|
||||
type: string
|
||||
type: object
|
||||
noProxy:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
type:
|
||||
description: |-
|
||||
VaultType represents the type of vault that can be used in the application.
|
||||
It is used to identify which vault integration should be used to resolve secrets.
|
||||
type: string
|
||||
type: object
|
||||
required:
|
||||
- githubConfigSecret
|
||||
- githubConfigUrl
|
||||
|
||||
@@ -7778,6 +7778,53 @@ spec:
|
||||
required:
|
||||
- containers
|
||||
type: object
|
||||
vaultConfig:
|
||||
properties:
|
||||
azureKeyVault:
|
||||
properties:
|
||||
certificatePath:
|
||||
type: string
|
||||
clientId:
|
||||
type: string
|
||||
tenantId:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
required:
|
||||
- certificatePath
|
||||
- clientId
|
||||
- tenantId
|
||||
- url
|
||||
type: object
|
||||
proxy:
|
||||
properties:
|
||||
http:
|
||||
properties:
|
||||
credentialSecretRef:
|
||||
type: string
|
||||
url:
|
||||
description: Required
|
||||
type: string
|
||||
type: object
|
||||
https:
|
||||
properties:
|
||||
credentialSecretRef:
|
||||
type: string
|
||||
url:
|
||||
description: Required
|
||||
type: string
|
||||
type: object
|
||||
noProxy:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
type:
|
||||
description: |-
|
||||
VaultType represents the type of vault that can be used in the application.
|
||||
It is used to identify which vault integration should be used to resolve secrets.
|
||||
type: string
|
||||
type: object
|
||||
required:
|
||||
- githubConfigSecret
|
||||
- githubConfigUrl
|
||||
|
||||
@@ -45,6 +45,7 @@ metadata:
|
||||
{{- if and (ne $containerMode.type "kubernetes") (not .Values.template.spec.serviceAccountName) }}
|
||||
actions.github.com/cleanup-no-permission-service-account-name: {{ include "gha-runner-scale-set.noPermissionServiceAccountName" . }}
|
||||
{{- end }}
|
||||
|
||||
spec:
|
||||
githubConfigUrl: {{ required ".Values.githubConfigUrl is required" (trimSuffix "/" .Values.githubConfigUrl) }}
|
||||
githubConfigSecret: {{ include "gha-runner-scale-set.githubsecret" . }}
|
||||
@@ -65,6 +66,24 @@ spec:
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if and .Values.keyVault .Values.keyVault.type }}
|
||||
vaultConfig:
|
||||
type: {{ .Values.keyVault.type }}
|
||||
{{- if .Values.keyVault.proxy }}
|
||||
proxy: {{- toYaml .Values.keyVault.proxy | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- if eq .Values.keyVault.type "azure_key_vault" }}
|
||||
azureKeyVault:
|
||||
url: {{ .Values.keyVault.azureKeyVault.url }}
|
||||
tenantId: {{ .Values.keyVault.azureKeyVault.tenantId }}
|
||||
clientId: {{ .Values.keyVault.azureKeyVault.clientId }}
|
||||
certificatePath: {{ .Values.keyVault.azureKeyVault.certificatePath }}
|
||||
secretKey: {{ .Values.keyVault.azureKeyVault.secretKey }}
|
||||
{{- else }}
|
||||
{{- fail "Unsupported keyVault type: " .Values.keyVault.type }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if .Values.proxy }}
|
||||
proxy:
|
||||
{{- if .Values.proxy.http }}
|
||||
|
||||
@@ -1158,7 +1158,7 @@ func TestTemplateRenderedWithTLS(t *testing.T) {
|
||||
ars := render(t, options)
|
||||
|
||||
require.NotNil(t, ars.Spec.GitHubServerTLS)
|
||||
expected := &v1alpha1.GitHubServerTLSConfig{
|
||||
expected := &v1alpha1.TLSConfig{
|
||||
CertificateFrom: &v1alpha1.TLSCertificateSource{
|
||||
ConfigMapKeyRef: &corev1.ConfigMapKeySelector{
|
||||
LocalObjectReference: corev1.LocalObjectReference{
|
||||
@@ -1218,7 +1218,7 @@ func TestTemplateRenderedWithTLS(t *testing.T) {
|
||||
ars := render(t, options)
|
||||
|
||||
require.NotNil(t, ars.Spec.GitHubServerTLS)
|
||||
expected := &v1alpha1.GitHubServerTLSConfig{
|
||||
expected := &v1alpha1.TLSConfig{
|
||||
CertificateFrom: &v1alpha1.TLSCertificateSource{
|
||||
ConfigMapKeyRef: &corev1.ConfigMapKeySelector{
|
||||
LocalObjectReference: corev1.LocalObjectReference{
|
||||
@@ -1278,7 +1278,7 @@ func TestTemplateRenderedWithTLS(t *testing.T) {
|
||||
ars := render(t, options)
|
||||
|
||||
require.NotNil(t, ars.Spec.GitHubServerTLS)
|
||||
expected := &v1alpha1.GitHubServerTLSConfig{
|
||||
expected := &v1alpha1.TLSConfig{
|
||||
CertificateFrom: &v1alpha1.TLSCertificateSource{
|
||||
ConfigMapKeyRef: &corev1.ConfigMapKeySelector{
|
||||
LocalObjectReference: corev1.LocalObjectReference{
|
||||
@@ -1338,7 +1338,7 @@ func TestTemplateRenderedWithTLS(t *testing.T) {
|
||||
ars := render(t, options)
|
||||
|
||||
require.NotNil(t, ars.Spec.GitHubServerTLS)
|
||||
expected := &v1alpha1.GitHubServerTLSConfig{
|
||||
expected := &v1alpha1.TLSConfig{
|
||||
CertificateFrom: &v1alpha1.TLSCertificateSource{
|
||||
ConfigMapKeyRef: &corev1.ConfigMapKeySelector{
|
||||
LocalObjectReference: corev1.LocalObjectReference{
|
||||
@@ -1394,7 +1394,7 @@ func TestTemplateRenderedWithTLS(t *testing.T) {
|
||||
ars := render(t, options)
|
||||
|
||||
require.NotNil(t, ars.Spec.GitHubServerTLS)
|
||||
expected := &v1alpha1.GitHubServerTLSConfig{
|
||||
expected := &v1alpha1.TLSConfig{
|
||||
CertificateFrom: &v1alpha1.TLSCertificateSource{
|
||||
ConfigMapKeyRef: &corev1.ConfigMapKeySelector{
|
||||
LocalObjectReference: corev1.LocalObjectReference{
|
||||
@@ -1450,7 +1450,7 @@ func TestTemplateRenderedWithTLS(t *testing.T) {
|
||||
ars := render(t, options)
|
||||
|
||||
require.NotNil(t, ars.Spec.GitHubServerTLS)
|
||||
expected := &v1alpha1.GitHubServerTLSConfig{
|
||||
expected := &v1alpha1.TLSConfig{
|
||||
CertificateFrom: &v1alpha1.TLSCertificateSource{
|
||||
ConfigMapKeyRef: &corev1.ConfigMapKeySelector{
|
||||
LocalObjectReference: corev1.LocalObjectReference{
|
||||
@@ -2468,3 +2468,43 @@ func TestNamespaceOverride(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAutoscalingRunnerSetCustomAnnotationsAndLabelsApplied(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Path to the helm chart we will test
|
||||
helmChartPath, err := filepath.Abs("../../gha-runner-scale-set")
|
||||
require.NoError(t, err)
|
||||
|
||||
releaseName := "test-runners"
|
||||
namespaceName := "test-" + strings.ToLower(random.UniqueId())
|
||||
|
||||
options := &helm.Options{
|
||||
Logger: logger.Discard,
|
||||
SetValues: map[string]string{
|
||||
"githubConfigUrl": "https://github.com/actions",
|
||||
"githubConfigSecret.github_token": "gh_token12345",
|
||||
"controllerServiceAccount.name": "arc",
|
||||
"controllerServiceAccount.namespace": "arc-system",
|
||||
"annotations.actions\\.github\\.com/vault": "azure_key_vault",
|
||||
"annotations.actions\\.github\\.com/cleanup-manager-role-name": "not-propagated",
|
||||
"labels.custom": "custom",
|
||||
"labels.app\\.kubernetes\\.io/component": "not-propagated",
|
||||
},
|
||||
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
|
||||
}
|
||||
|
||||
output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/autoscalingrunnerset.yaml"})
|
||||
|
||||
var autoscalingRunnerSet v1alpha1.AutoscalingRunnerSet
|
||||
helm.UnmarshalK8SYaml(t, output, &autoscalingRunnerSet)
|
||||
|
||||
vault := autoscalingRunnerSet.Annotations["actions.github.com/vault"]
|
||||
assert.Equal(t, "azure_key_vault", vault)
|
||||
|
||||
custom := autoscalingRunnerSet.Labels["custom"]
|
||||
assert.Equal(t, "custom", custom)
|
||||
|
||||
assert.NotEqual(t, "not-propagated", autoscalingRunnerSet.Annotations["actions.github.com/cleanup-manager-role-name"])
|
||||
assert.NotEqual(t, "not-propagated", autoscalingRunnerSet.Labels["app.kubernetes.io/component"])
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ githubConfigUrl: ""
|
||||
## You can choose to supply:
|
||||
## A) a PAT token,
|
||||
## B) a GitHub App, or
|
||||
## C) a pre-defined Kubernetes secret.
|
||||
## C) a pre-defined secret.
|
||||
## The syntax for each of these variations is documented below.
|
||||
## (Variation A) When using a PAT token, the syntax is as follows:
|
||||
githubConfigSecret:
|
||||
@@ -28,8 +28,11 @@ githubConfigSecret:
|
||||
# .
|
||||
# private key line N
|
||||
#
|
||||
## (Variation C) When using a pre-defined Kubernetes secret in the same namespace that the gha-runner-scale-set is going to deploy,
|
||||
## the syntax is as follows:
|
||||
## (Variation C) When using a pre-defined secret.
|
||||
## The secret can be pulled either directly from Kubernetes, or from the vault, depending on configuration.
|
||||
## Kubernetes secret in the same namespace that the gha-runner-scale-set is going to deploy.
|
||||
## On the other hand, if the vault is configured, secret name will be used to fetch the app configuration.
|
||||
## The syntax is as follows:
|
||||
# githubConfigSecret: pre-defined-secret
|
||||
## Notes on using pre-defined Kubernetes secrets:
|
||||
## You need to make sure your predefined secret has all the required secret data set properly.
|
||||
@@ -85,6 +88,26 @@ githubConfigSecret:
|
||||
# key: ca.crt
|
||||
# runnerMountPath: /usr/local/share/ca-certificates/
|
||||
|
||||
# keyVault:
|
||||
# Available values: "azure_key_vault"
|
||||
# type: ""
|
||||
# Configuration related to azure key vault
|
||||
# azure_key_vault:
|
||||
# url: ""
|
||||
# client_id: ""
|
||||
# tenant_id: ""
|
||||
# certificate_path: ""
|
||||
# proxy:
|
||||
# http:
|
||||
# url: http://proxy.com:1234
|
||||
# credentialSecretRef: proxy-auth # a secret with `username` and `password` keys
|
||||
# https:
|
||||
# url: http://proxy.com:1234
|
||||
# credentialSecretRef: proxy-auth # a secret with `username` and `password` keys
|
||||
# noProxy:
|
||||
# - example.com
|
||||
# - example.org
|
||||
|
||||
## Container mode is an object that provides out-of-box configuration
|
||||
## for dind and kubernetes mode. Template will be modified as documented under the
|
||||
## template object.
|
||||
|
||||
Reference in New Issue
Block a user