Skip to content
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

Fix issue for debug containers when using custom Docker registry #3873

Merged
merged 11 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions charts/linkerd2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ The following table lists the configurable parameters of the Linkerd2 chart and
| `controllerReplicas` | Number of replicas for each control plane pod | `1` |
| `controllerUID` | User ID for the control plane components | `2103` |
| `dashboard.replicas` | Number of replicas of dashboard | `1` |
| `debugContainer.image.name` | Docker image for the debug container | `gcr.io/linkerd-io/debug` |
| `debugContainer.image.pullPolicy` | Pull policy for the debug container Docker image | `IfNotPresent` |
| `debugContainer.image.version` | Tag for the debug container Docker image | latest version |
| `disableHeartBeat` | Set to true to not start the heartbeat cronjob | `false` |
| `enableH2Upgrade` | Allow proxies to perform transparent HTTP/2 upgrading | `true` |
| `global.clusterDomain` | Kubernetes DNS Domain name to use | `cluster.local` |
Expand Down Expand Up @@ -122,7 +125,7 @@ The following table lists the configurable parameters of the Linkerd2 chart and
| `global.proxyInit.ignoreOutboundPorts` | Outbound ports the proxy should ignore ||
| `global.proxyInit.image.name` | Docker image for the proxy-init container | `gcr.io/linkerd-io/proxy-init` |
| `global.proxyInit.image.pullPolicy` | Pull policy for the proxy-init container Docker image | `IfNotPresent` |
| `global.proxyInit.image.version` | Tag for the proxy-init container Docker image | `v1.1.0` |
| `global.proxyInit.image.version` | Tag for the proxy-init container Docker image | latest version |
| `global.proxyInit.resources.cpu.limit` | Maximum amount of CPU units that the proxy-init container can use | `100m` |
| `global.proxyInit.resources.cpu.request` | Amount of CPU units that the proxy-init container requests | `10m` |
| `global.ProxyInit.resources.memory.limit` | Maximum amount of memory that the proxy-init container can use | `50Mi` |
Expand All @@ -148,7 +151,7 @@ The following table lists the configurable parameters of the Linkerd2 chart and
| `profileValidator.keyPEM` | Certificate key for the service profile validator. If not provided then Helm will generate one. ||
| `tap.crtPEM` | Certificate for the Tap component. If not provided then Helm will generate one. ||
| `tap.keyPEM` | Certificate key for Tap component. If not provided then Helm will generate one. ||
| `webhookFailurePolicy` | Failure policy for the proxy injector | `Ignore`
| `webhookFailurePolicy` | Failure policy for the proxy injector | `Ignore` |
| `webImage` | Docker image for the web container | `gcr.io/linkerd-io/web` |

## Get involved
Expand Down
7 changes: 6 additions & 1 deletion charts/linkerd2/templates/_config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@
},
"disableExternalProfiles": {{not .Values.global.proxy.enableExternalProfiles}},
"proxyVersion": "{{.Values.global.proxy.image.version}}",
"proxyInitImageVersion": "{{.Values.global.proxyInit.image.version}}"
"proxyInitImageVersion": "{{.Values.global.proxyInit.image.version}}",
"debugImage":{
"imageName":"{{.Values.debugContainer.image.name}}",
"pullPolicy":"{{.Values.debugContainer.image.pullPolicy}}"
},
"debugImageVersion": "{{.Values.debugContainer.image.version}}"
}
{{- end -}}

Expand Down
7 changes: 7 additions & 0 deletions charts/linkerd2/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ controllerUID: 2103
dashboard:
replicas: 1

# debug configuration
debugContainer:
image:
name: gcr.io/linkerd-io/debug
pullPolicy: *image_pull_policy
version: *linkerd_version

# identity configuration
identity:
issuer:
Expand Down
12 changes: 12 additions & 0 deletions cli/cmd/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ func generateAnnotationsDocs() []annotationDoc {
Name: k8s.ProxyInitImageVersionAnnotation,
Description: "Linkerd init container image version",
},
{
Name: k8s.DebugImageAnnotation,
Description: "Linkerd debug container image name",
},
{
Name: k8s.DebugImageVersionAnnotation,
Description: "Linkerd debug container image version",
},
{
Name: k8s.DebugImagePullPolicyAnnotation,
Description: "Docker image pull policy for debug image",
},
{
Name: k8s.ProxyControlPortAnnotation,
Description: "Proxy port to use for control",
Expand Down
29 changes: 25 additions & 4 deletions cli/cmd/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
injectDisabledDesc = "pods are not annotated to disable injection"
unsupportedDesc = "at least one resource injected"
udpDesc = "pod specs do not include UDP ports"
slash = "/"
)

type resourceTransformerInject struct {
Expand Down Expand Up @@ -367,10 +368,13 @@ func (options *proxyConfigOptions) overrideConfigs(configs *cfg.All, overrideAnn
}

if options.dockerRegistry != "" {
configs.Proxy.ProxyImage.ImageName = registryOverride(configs.Proxy.ProxyImage.ImageName, options.dockerRegistry)
configs.Proxy.ProxyInitImage.ImageName = registryOverride(configs.Proxy.ProxyInitImage.ImageName, options.dockerRegistry)
overrideAnnotations[k8s.ProxyImageAnnotation] = configs.Proxy.ProxyImage.ImageName
overrideAnnotations[k8s.ProxyInitImageAnnotation] = configs.Proxy.ProxyInitImage.ImageName
debugImage := configs.GetProxy().GetDebugImage().GetImageName()
if debugImage == "" {
debugImage = k8s.DebugSidecarImage
}
overrideAnnotations[k8s.ProxyImageAnnotation] = overwriteRegistry(configs.GetProxy().GetProxyImage().GetImageName(), options.dockerRegistry)
overrideAnnotations[k8s.ProxyInitImageAnnotation] = overwriteRegistry(configs.GetProxy().GetProxyInitImage().GetImageName(), options.dockerRegistry)
overrideAnnotations[k8s.DebugImageAnnotation] = overwriteRegistry(debugImage, options.dockerRegistry)
javaducky marked this conversation as resolved.
Show resolved Hide resolved
}

if options.proxyImage != "" {
Expand All @@ -392,6 +396,7 @@ func (options *proxyConfigOptions) overrideConfigs(configs *cfg.All, overrideAnn
if options.imagePullPolicy != "" {
configs.Proxy.ProxyImage.PullPolicy = options.imagePullPolicy
configs.Proxy.ProxyInitImage.PullPolicy = options.imagePullPolicy
configs.Proxy.DebugImage.PullPolicy = options.imagePullPolicy
overrideAnnotations[k8s.ProxyImagePullPolicyAnnotation] = options.imagePullPolicy
}

Expand Down Expand Up @@ -479,3 +484,19 @@ func parsePortRanges(portRanges []*cfg.PortRange) string {

return strings.TrimSuffix(str, ",")
}

// overwriteRegistry replaces the registry-portion of the provided image with the provided registry.
func overwriteRegistry(image, newRegistry string) string {
if image == "" {
return image
}
registry := newRegistry
if registry != "" && !strings.HasSuffix(registry, slash) {
registry += slash
}
imageName := image
if strings.Contains(image, slash) {
imageName = image[strings.LastIndex(image, slash)+1:]
}
return registry + imageName
}
Loading