-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into k0s-1-29
- Loading branch information
Showing
17 changed files
with
704 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"testing" | ||
|
||
"github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1" | ||
"github.com/stretchr/testify/require" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func Test_getCIDRs(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
buildCliContext func(*flag.FlagSet) *cli.Context | ||
expected []string | ||
}{ | ||
{ | ||
name: "with pod and service flags", | ||
expected: []string{ | ||
"10.0.0.0/24", | ||
"10.1.0.0/24", | ||
"", | ||
}, | ||
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context { | ||
c := cli.NewContext(cli.NewApp(), flagSet, nil) | ||
c.Set("pod-cidr", "10.0.0.0/24") | ||
c.Set("service-cidr", "10.1.0.0/24") | ||
return c | ||
}, | ||
}, | ||
{ | ||
name: "with pod flag", | ||
expected: []string{ | ||
"10.0.0.0/24", | ||
v1beta1.DefaultNetwork().ServiceCIDR, | ||
"", | ||
}, | ||
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context { | ||
c := cli.NewContext(cli.NewApp(), flagSet, nil) | ||
c.Set("pod-cidr", "10.0.0.0/24") | ||
return c | ||
}, | ||
}, | ||
{ | ||
name: "with pod, service and cidr flags", | ||
expected: []string{ | ||
"10.0.0.0/24", | ||
"10.1.0.0/24", | ||
"", | ||
}, | ||
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context { | ||
c := cli.NewContext(cli.NewApp(), flagSet, nil) | ||
c.Set("pod-cidr", "10.0.0.0/24") | ||
c.Set("service-cidr", "10.1.0.0/24") | ||
c.Set("cidr", "10.2.0.0/24") | ||
return c | ||
}, | ||
}, | ||
{ | ||
name: "with pod and cidr flags", | ||
expected: []string{ | ||
"10.0.0.0/24", | ||
v1beta1.DefaultNetwork().ServiceCIDR, | ||
"", | ||
}, | ||
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context { | ||
c := cli.NewContext(cli.NewApp(), flagSet, nil) | ||
c.Set("pod-cidr", "10.0.0.0/24") | ||
c.Set("cidr", "10.2.0.0/24") | ||
return c | ||
}, | ||
}, | ||
{ | ||
name: "with cidr flag", | ||
expected: []string{ | ||
"", | ||
"", | ||
"10.2.0.0/24", | ||
}, | ||
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context { | ||
c := cli.NewContext(cli.NewApp(), flagSet, nil) | ||
c.Set("cidr", "10.2.0.0/24") | ||
return c | ||
}, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
req := require.New(t) | ||
|
||
flagSet := flag.NewFlagSet(t.Name(), 0) | ||
flags := withSubnetCIDRFlags([]cli.Flag{}) | ||
for _, f := range flags { | ||
err := f.Apply(flagSet) | ||
req.NoError(err) | ||
} | ||
|
||
cc := test.buildCliContext(flagSet) | ||
podCIDR, serviceCIDR, CIDR := getCIDRs(cc) | ||
req.Equal(test.expected[0], podCIDR) | ||
req.Equal(test.expected[1], serviceCIDR) | ||
req.Equal(test.expected[2], CIDR) | ||
}) | ||
} | ||
} | ||
|
||
func Test_DeterminePodAndServiceCIDRs(t *testing.T) { | ||
|
||
tests := []struct { | ||
name string | ||
buildCliContext func(*flag.FlagSet) *cli.Context | ||
expected []string | ||
}{ | ||
{ | ||
name: "with pod flag", | ||
expected: []string{ | ||
"10.0.0.0/16", | ||
v1beta1.DefaultNetwork().ServiceCIDR, | ||
}, | ||
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context { | ||
c := cli.NewContext(cli.NewApp(), flagSet, nil) | ||
c.Set("pod-cidr", "10.0.0.0/16") | ||
return c | ||
}, | ||
}, | ||
{ | ||
name: "with service flag", | ||
expected: []string{ | ||
v1beta1.DefaultNetwork().PodCIDR, | ||
"10.1.0.0/16", | ||
}, | ||
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context { | ||
c := cli.NewContext(cli.NewApp(), flagSet, nil) | ||
c.Set("service-cidr", "10.1.0.0/16") | ||
return c | ||
}, | ||
}, | ||
{ | ||
name: "with cidr flag", | ||
expected: []string{ | ||
"10.0.0.0/16", | ||
"10.1.0.0/16", | ||
}, | ||
buildCliContext: func(flagSet *flag.FlagSet) *cli.Context { | ||
c := cli.NewContext(cli.NewApp(), flagSet, nil) | ||
c.Set("cidr", "10.0.0.0/15") | ||
return c | ||
}, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
req := require.New(t) | ||
|
||
flagSet := flag.NewFlagSet(t.Name(), 0) | ||
flags := withSubnetCIDRFlags([]cli.Flag{}) | ||
for _, f := range flags { | ||
err := f.Apply(flagSet) | ||
req.NoError(err) | ||
} | ||
|
||
cc := test.buildCliContext(flagSet) | ||
podCIDR, serviceCIDR, err := DeterminePodAndServiceCIDRs(cc) | ||
req.NoError(err) | ||
req.Equal(test.expected[0], podCIDR) | ||
req.Equal(test.expected[1], serviceCIDR) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
operator/charts/embedded-cluster-operator/templates/embedded-cluster-lam-service-config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: embedded-cluster-lam-service-config | ||
labels: | ||
troubleshoot.sh/kind: support-bundle | ||
{{- with (include "embedded-cluster-operator.labels" $ | fromYaml) }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
data: | ||
support-bundle-spec: | | ||
apiVersion: troubleshoot.sh/v1beta2 | ||
kind: SupportBundle | ||
metadata: | ||
name: embedded-cluster-lam-service-config | ||
labels: | ||
troubleshoot.sh/kind: support-bundle | ||
spec: | ||
collectors: | ||
- runDaemonSet: | ||
name: "local-artifact-mirror-service-config" | ||
namespace: embedded-cluster | ||
podSpec: | ||
containers: | ||
- image: {{ .Values.utilsImage }} | ||
imagePullPolicy: Always | ||
args: ["chroot","/host","cat","/etc/systemd/system/local-artifact-mirror.service.d/embedded-cluster.conf"] | ||
name: debugger | ||
resources: {} | ||
terminationMessagePath: /dev/termination-log | ||
terminationMessagePolicy: File | ||
volumeMounts: | ||
- mountPath: /host | ||
name: host-root | ||
dnsPolicy: ClusterFirst | ||
enableServiceLinks: true | ||
hostIPC: true | ||
hostNetwork: true | ||
hostPID: true | ||
securityContext: | ||
runAsUser: 0 | ||
tolerations: | ||
- operator: Exists | ||
volumes: | ||
- hostPath: | ||
path: / | ||
type: "" | ||
name: host-root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.