-
-
Notifications
You must be signed in to change notification settings - Fork 373
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 flexible ImagePullSecrets
support
#1897
Conversation
Just a general comment: local variables, e.g. as arguments, always should be lowercase. |
And to get a list instead of a string, use a |
@@ -53,3 +53,9 @@ helm upgrade --install woodpecker-agent --namespace <namespace> woodpecker/woodp | |||
# Uninstall | |||
helm delete woodpecker-agent | |||
``` | |||
|
|||
## ImagePullSecrets |
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.
Shouldn't it be in docs/docs/30-administration/22-backends/40-kubernetes.md? There also should be description of the env var.
## ImagePullSecrets | ||
|
||
By default pods look for a secret named "regcred" in the respective namespace. | ||
Existing secrets can be used by overwriting the default secret name Woodpecker is looking for via the k8s backend option `backend-k8s-pod-image-pull-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.
Existing secrets can be used by overwriting the default secret name Woodpecker is looking for via the k8s backend option `backend-k8s-pod-image-pull-secret`. | |
Existing secrets can be used by overwriting the default secret name Woodpecker is looking for via the `WOODPECKER_BACKEND_K8S_IMAGE_PULL_SECRETS` environment variable. |
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.
You need to adjust the code, but these comments should help you getting it right
&cli.StringFlag{ | ||
EnvVars: []string{"WOODPECKER_BACKEND_K8S_IMAGE_PULL_SECRETS"}, | ||
Name: "backend-k8s-pod-image-pull-secrets", | ||
Usage: "backend k8s pull secrets for private registries", | ||
Value: "regcred", | ||
}, |
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.
&cli.StringFlag{ | |
EnvVars: []string{"WOODPECKER_BACKEND_K8S_IMAGE_PULL_SECRETS"}, | |
Name: "backend-k8s-pod-image-pull-secrets", | |
Usage: "backend k8s pull secrets for private registries", | |
Value: "regcred", | |
}, | |
&cli.StringSliceFlag{ | |
EnvVars: []string{"WOODPECKER_BACKEND_K8S_IMAGE_PULL_SECRETS"}, | |
Name: "backend-k8s-pod-image-pull-secrets", | |
Usage: "backend k8s pull secrets for private registries", | |
Value: []string{}, | |
}, |
&cli.StringFlag{ | ||
EnvVars: []string{"WOODPECKER_BACKEND_K8S_IMAGE_PULL_SECRETS"}, | ||
Name: "backend-k8s-pod-image-pull-secrets", | ||
Usage: "backend k8s pull secrets for private registries", | ||
Value: "regcred", |
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.
&cli.StringFlag{ | |
EnvVars: []string{"WOODPECKER_BACKEND_K8S_IMAGE_PULL_SECRETS"}, | |
Name: "backend-k8s-pod-image-pull-secrets", | |
Usage: "backend k8s pull secrets for private registries", | |
Value: "regcred", | |
&cli.StringSliceFlag{ | |
EnvVars: []string{"WOODPECKER_BACKEND_K8S_IMAGE_PULL_SECRETS"}, | |
Name: "backend-k8s-pod-image-pull-secrets", | |
Usage: "backend k8s pull secrets for private registries", | |
Value: []string{}, | |
}, |
@@ -11,7 +11,7 @@ import ( | |||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | |||
) | |||
|
|||
func Pod(namespace string, step *types.Step, labels, annotations map[string]string) (*v1.Pod, error) { | |||
func Pod(namespace string, step *types.Step, labels, annotations map[string]string, ImagePullSecrets) (*v1.Pod, error) { |
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.
func Pod(namespace string, step *types.Step, labels, annotations map[string]string, ImagePullSecrets) (*v1.Pod, error) { | |
func Pod(namespace string, step *types.Step, labels, annotations map[string]string, imagePullSecrets []v1.LocalObjectReference) (*v1.Pod, error) { |
Nice PR. Is it possible to assume some default? In general, ServiceAccounts already have this configuration, if we don't set anything they use the configuration inside ServiceAccount. |
Currently
ImagePullSecrets
is hardcoded to a secret namedregcred
:woodpecker/pipeline/backend/kubernetes/pod.go
Line 135 in e1c31df
This PR aims to make it more flexible and let users specify multiple secrets via a server-wide k8s backend option, similar to labels and annotations.
@woodpecker-ci/maintainers
My golang skils are limited and I've added some
FIXME
s in places where I need help for a "proper" implementation.