Skip to content
Open
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
6 changes: 3 additions & 3 deletions cni-plugin/pkg/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"encoding/json"
"fmt"
"io"
"net"
"os"
"runtime"
"strconv"
Expand Down Expand Up @@ -478,7 +479,7 @@ kind: Config
clusters:
- name: local
cluster:
server: __KUBERNETES_SERVICE_PROTOCOL__://[__KUBERNETES_SERVICE_HOST__]:__KUBERNETES_SERVICE_PORT__
server: __KUBERNETES_SERVICE_PROTOCOL__://__KUBERNETES_HOST_PORT__
__TLS_CFG__
users:
- name: calico
Expand All @@ -502,8 +503,7 @@ current-context: calico-context`
}
data = strings.Replace(data, "TOKEN", tu.Token, 1)
data = strings.ReplaceAll(data, "__KUBERNETES_SERVICE_PROTOCOL__", getEnv("KUBERNETES_SERVICE_PROTOCOL", "https"))
data = strings.ReplaceAll(data, "__KUBERNETES_SERVICE_HOST__", getEnv("KUBERNETES_SERVICE_HOST", ""))
data = strings.ReplaceAll(data, "__KUBERNETES_SERVICE_PORT__", getEnv("KUBERNETES_SERVICE_PORT", ""))
data = strings.ReplaceAll(data, "__KUBERNETES_HOST_PORT__", net.JoinHostPort(getEnv("KUBERNETES_SERVICE_HOST", ""), getEnv("KUBERNETES_SERVICE_PORT", "")))
Copy link
Member

@caseydavenport caseydavenport Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data = strings.ReplaceAll(data, "__KUBERNETES_HOST_PORT__", net.JoinHostPort(getEnv("KUBERNETES_SERVICE_HOST", ""), getEnv("KUBERNETES_SERVICE_PORT", "")))
data = strings.ReplaceAll(data, "__KUBERNETES_SERVICE_HOST__", getEnv("KUBERNETES_SERVICE_HOST", ""))
data = strings.ReplaceAll(data, "__KUBERNETES_SERVICE_PORT__", getEnv("KUBERNETES_SERVICE_PORT", ""))
data = strings.ReplaceAll(data, "__KUBERNETES_SERVICE__", net.JoinHostPort(getEnv("KUBERNETES_SERVICE_HOST", ""), getEnv("KUBERNETES_SERVICE_PORT", "")))

I think we need to leave the existing replace statements - some users provide their own CNI configuration templates and may be relying on this replacement. Just because they aren't used by the default config template doesn't mean they might not be used elsewhere.

Let's also call it KUBERNETES_SERVICE since HOST_PORT has a meaning already in k8s networking.


skipTLSVerify := os.Getenv("SKIP_TLS_VERIFY")
if skipTLSVerify == "true" {
Expand Down