Skip to content

Commit b3b35d8

Browse files
committed
Workaround konnectivity ingress issue
Signed-off-by: Alexey Makhov <[email protected]> Signed-off-by: makhov <[email protected]>
1 parent 6f3016f commit b3b35d8

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

e2e/ingress_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"path/filepath"
2626
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2727
"sigs.k8s.io/controller-runtime/pkg/client"
28+
"strings"
2829
"testing"
2930
"time"
3031

@@ -152,6 +153,14 @@ func ingressSupportSpec(t *testing.T) {
152153
clusterv1.ClusterNameLabel: workloadClusterName,
153154
}), "Should list machines")
154155

156+
out, err := exec.Command("/bin/sh", "-c", fmt.Sprintf(`docker ps | grep control-plane | awk '{print $1}'`)).Output()
157+
t.Log(string(out))
158+
require.NoError(t, err, "Should list test control plane container")
159+
containerName := strings.Trim(string(out), "\n ")
160+
cmd := exec.Command("docker", "exec", workloadClusterName, "kubectl", "exec ", "-n", "k0smotron", containerName, "--", "k0s", "kc", "logs", "-n", "kube-system", "ds/konnectivity-agent")
161+
out, err = cmd.CombinedOutput()
162+
t.Logf("Konnectivity agent logs:\n%s", string(out))
163+
155164
for _, m := range machineList.Items {
156165
var (
157166
stdout bytes.Buffer

internal/controller/k0smotron.io/k0smotroncluster_configmap.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ func getV1Beta1Spec(kmc *km.Cluster, sans []string) map[string]interface{} {
281281
}
282282
v1beta1Spec["konnectivity"] = map[string]any{
283283
"externalAddress": kmc.Spec.Ingress.KonnectivityHost,
284-
"agentPort": kmc.Spec.Ingress.Port,
285284
}
286285
}
287286

internal/controller/k0smotron.io/k0smotroncluster_ingress.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,74 @@ spec:
167167
app: k0smotron-haproxy
168168
sessionAffinity: None
169169
type: ClusterIP`, scope.clusterSettings.kubernetesServiceIP, scope.clusterSettings.kubernetesServiceIP),
170+
"4_konnectivity.yaml": fmt.Sprintf(`apiVersion: apps/v1
171+
kind: DaemonSet
172+
metadata:
173+
labels:
174+
k8s-app: konnectivity-agent
175+
namespace: kube-system
176+
name: konnectivity-agent
177+
spec:
178+
selector:
179+
matchLabels:
180+
k8s-app: konnectivity-agent
181+
template:
182+
metadata:
183+
labels:
184+
k8s-app: konnectivity-agent
185+
annotations:
186+
prometheus.io/scrape: 'true'
187+
prometheus.io/port: '8093'
188+
spec:
189+
securityContext:
190+
runAsNonRoot: true
191+
supplementalGroups: [0]
192+
nodeSelector:
193+
kubernetes.io/os: linux
194+
priorityClassName: system-cluster-critical
195+
tolerations:
196+
- operator: Exists
197+
containers:
198+
- image: quay.io/k0sproject/apiserver-network-proxy-agent:v0.33.0
199+
imagePullPolicy: IfNotPresent
200+
name: konnectivity-agent
201+
command: ["/proxy-agent"]
202+
env:
203+
- name: NODE_IP
204+
valueFrom:
205+
fieldRef:
206+
fieldPath: status.hostIP
207+
args:
208+
- --logtostderr=true
209+
- --ca-cert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
210+
- --proxy-server-host=%s
211+
- --proxy-server-port=%d
212+
- --service-account-token-path=/var/run/secrets/tokens/konnectivity-agent-token
213+
- --agent-identifiers=host=$(NODE_IP)
214+
- --agent-id=$(NODE_IP)
215+
volumeMounts:
216+
- mountPath: /var/run/secrets/tokens
217+
name: konnectivity-agent-token
218+
livenessProbe:
219+
httpGet:
220+
port: 8093
221+
path: /healthz
222+
initialDelaySeconds: 15
223+
timeoutSeconds: 15
224+
readinessProbe:
225+
httpGet:
226+
port: 8093
227+
path: /readyz
228+
initialDelaySeconds: 15
229+
timeoutSeconds: 15
230+
serviceAccountName: konnectivity-agent
231+
volumes:
232+
- name: konnectivity-agent-token
233+
projected:
234+
sources:
235+
- serviceAccountToken:
236+
path: konnectivity-agent-token
237+
audience: system:konnectivity-server`, kmc.Spec.Ingress.KonnectivityHost, kmc.Spec.Ingress.Port),
170238
},
171239
}
172240

0 commit comments

Comments
 (0)