Skip to content

Commit

Permalink
Add dualstack configuration (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
bschimke95 committed Jun 3, 2024
1 parent e5779fa commit 94f45db
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/k8s/pkg/k8sd/features/cilium/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ func ApplyNetwork(ctx context.Context, snap snap.Snap, cfg types.Network) error
"useDigest": false,
},
},
"ipv4": map[string]any{
"enabled": ipv4CIDR != "",
},
"ipv6": map[string]any{
"enabled": ipv6CIDR != "",
},
"ipam": map[string]any{
"operator": map[string]any{
"clusterPoolIPv4PodCIDRList": ipv4CIDR,
Expand Down
13 changes: 13 additions & 0 deletions src/k8s/pkg/k8sd/setup/kube_apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ func TestKubeAPIServer(t *testing.T) {
g.Expect(len(args)).To(Equal(len(tests)))
})

t.Run("ArgsDualstack", func(t *testing.T) {
g := NewWithT(t)

s := mustSetupSnapAndDirectories(t, setKubeAPIServerMock)

// Setup without proxy to simplify argument list
g.Expect(setup.KubeAPIServer(s, "10.0.0.0/24,fd01::/64", "https://auth-webhook.url", false, types.Datastore{Type: utils.Pointer("external"), ExternalServers: utils.Pointer([]string{"datastoreurl1", "datastoreurl2"})}, "Node,RBAC")).To(BeNil())

g.Expect(snaputil.GetServiceArgument(s, "kube-apiserver", "--service-cluster-ip-range")).To(Equal("10.0.0.0/24,fd01::/64"))
_, err := utils.ParseArgumentFile(path.Join(s.Mock.ServiceArgumentsDir, "kube-apiserver"))
g.Expect(err).ToNot(HaveOccurred())
})

t.Run("ArgsExternalDatastore", func(t *testing.T) {
g := NewWithT(t)

Expand Down
37 changes: 37 additions & 0 deletions tests/integration/templates/nginx-dualstack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginxdualstack
spec:
selector:
matchLabels:
run: nginxdualstack
replicas: 1
template:
metadata:
labels:
run: nginxdualstack
spec:
containers:
- name: nginxdualstack
image: rocks.canonical.com/cdk/diverdane/nginxdualstack:1.0.0
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx6
labels:
run: nginxdualstack
spec:
type: NodePort
ipFamilies:
- IPv4
- IPv6
ipFamilyPolicy: RequireDualStack
ports:
- port: 80
protocol: TCP
selector:
run: nginxdualstack

0 comments on commit 94f45db

Please sign in to comment.