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

feat(kumactl): add install control-plane --registry flag #4533

Merged
merged 3 commits into from
Jun 30, 2022
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: 7 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ does not have any particular instructions.

## Upcoming release

### Helm

Under `cni.image`, the default values for `repository` and `registry` have been
changed to agree with the other `image` values.

## Upgrade to `1.7.x`

### CP

* The `/versions` endpoint was removed. This is not something that was reliable enough and version compatibility
Expand Down
4 changes: 4 additions & 0 deletions app/kumactl/cmd/completion/testdata/bash.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3549,6 +3549,10 @@ _kumactl_install_control-plane()
two_word_flags+=("--namespace")
local_nonpersistent_flags+=("--namespace")
local_nonpersistent_flags+=("--namespace=")
flags+=("--registry=")
two_word_flags+=("--registry")
local_nonpersistent_flags+=("--registry")
local_nonpersistent_flags+=("--registry=")
flags+=("--set=")
two_word_flags+=("--set")
local_nonpersistent_flags+=("--set")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type InstallControlPlaneArgs struct {
Namespace string
ControlPlane_image_pullPolicy string `helm:"controlPlane.image.pullPolicy"`
ControlPlane_image_registry string `helm:"controlPlane.image.registry"`
ControlPlane_image_registry string `helm:"controlPlane.image.registry,omitempty"`
ControlPlane_image_repository string `helm:"controlPlane.image.repository"`
ControlPlane_image_tag string `helm:"controlPlane.image.tag"`
ControlPlane_service_name string `helm:"controlPlane.service.name"`
Expand All @@ -25,10 +25,10 @@ type InstallControlPlaneArgs struct {
ControlPlane_secrets []ImageEnvSecret `helm:"controlPlane.secrets"`
ControlPlane_envVars map[string]string `helm:"controlPlane.envVars"`
ControlPlane_nodeSelector map[string]string `helm:"controlPlane.nodeSelector"`
DataPlane_image_registry string `helm:"dataPlane.image.registry"`
DataPlane_image_registry string `helm:"dataPlane.image.registry,omitempty"`
DataPlane_image_repository string `helm:"dataPlane.image.repository"`
DataPlane_image_tag string `helm:"dataPlane.image.tag"`
DataPlane_initImage_registry string `helm:"dataPlane.initImage.registry"`
DataPlane_initImage_registry string `helm:"dataPlane.initImage.registry,omitempty"`
DataPlane_initImage_repository string `helm:"dataPlane.initImage.repository"`
DataPlane_initImage_tag string `helm:"dataPlane.initImage.tag"`
ControlPlane_kdsGlobalAddress string `helm:"controlPlane.kdsGlobalAddress"`
Expand All @@ -37,13 +37,14 @@ type InstallControlPlaneArgs struct {
Cni_net_dir string `helm:"cni.netDir"`
Cni_bin_dir string `helm:"cni.binDir"`
Cni_conf_name string `helm:"cni.confName"`
Cni_image_registry string `helm:"cni.image.registry"`
Cni_image_registry string `helm:"cni.image.registry,omitempty"`
Cni_image_repository string `helm:"cni.image.repository"`
Cni_image_tag string `helm:"cni.image.tag"`
Cni_nodeSelector map[string]string `helm:"cni.nodeSelector"`
ControlPlane_mode string `helm:"controlPlane.mode"`
ControlPlane_zone string `helm:"controlPlane.zone"`
ControlPlane_globalZoneSyncService_type string `helm:"controlPlane.globalZoneSyncService.type"`
Image_registry string `helm:"global.image.registry"`
Ingress_enabled bool `helm:"ingress.enabled"`
Ingress_mesh string `helm:"ingress.mesh"`
Ingress_drainTime string `helm:"ingress.drainTime"`
Expand Down Expand Up @@ -81,29 +82,30 @@ func DefaultInstallCpContext() InstallCpContext {
Args: InstallControlPlaneArgs{
Namespace: "kuma-system",
ControlPlane_image_pullPolicy: "IfNotPresent",
ControlPlane_image_registry: "docker.io/kumahq",
ControlPlane_image_registry: "",
ControlPlane_image_repository: "kuma-cp",
ControlPlane_image_tag: kuma_version.Build.Version,
ControlPlane_service_name: "kuma-control-plane",
ControlPlane_envVars: map[string]string{},
ControlPlane_injectorFailurePolicy: "Fail",
DataPlane_image_registry: "docker.io/kumahq",
DataPlane_image_registry: "",
DataPlane_image_repository: "kuma-dp",
DataPlane_image_tag: kuma_version.Build.Version,
DataPlane_initImage_registry: "docker.io/kumahq",
DataPlane_initImage_registry: "",
DataPlane_initImage_repository: "kuma-init",
DataPlane_initImage_tag: kuma_version.Build.Version,
Cni_enabled: false,
Cni_chained: false,
Cni_net_dir: "/etc/cni/multus/net.d",
Cni_bin_dir: "/var/lib/cni/bin",
Cni_conf_name: "kuma-cni.conf",
Cni_image_registry: "docker.io/kumahq",
Cni_image_registry: "",
Cni_image_repository: "install-cni",
Cni_image_tag: "0.0.10",
ControlPlane_mode: core.Standalone,
ControlPlane_zone: "",
ControlPlane_globalZoneSyncService_type: "LoadBalancer",
Image_registry: "docker.io/kumahq",
Ingress_enabled: false,
Ingress_mesh: "default",
Ingress_drainTime: "30s",
Expand Down
1 change: 1 addition & 0 deletions app/kumactl/cmd/install/install_control_plane.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ This command requires that the KUBECONFIG environment is set`,

cmd.Flags().Var(&componentVersion, "version", "version of Kuma Control Plane components")

cmd.Flags().StringVar(&args.Image_registry, "registry", args.Image_registry, "registry for all images")
cmd.Flags().StringVar(&args.ControlPlane_image_pullPolicy, "image-pull-policy", args.ControlPlane_image_pullPolicy, "image pull policy that applies to all components of the Kuma Control Plane")
cmd.Flags().StringVar(&args.ControlPlane_image_registry, "control-plane-registry", args.ControlPlane_image_registry, "registry for the image of the Kuma Control Plane component")
cmd.Flags().StringVar(&args.ControlPlane_image_repository, "control-plane-repository", args.ControlPlane_image_repository, "repository for the image of the Kuma Control Plane component")
Expand Down
7 changes: 7 additions & 0 deletions app/kumactl/cmd/install/install_control_plane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ var _ = Describe("kumactl install control-plane", func() {
},
goldenFile: "install-control-plane.overrides.golden.yaml",
}),
Entry("should generate Kubernetes resources with --registry", testCase{
extraArgs: []string{
"--registry", "gcr.io/octo",
"--dataplane-registry", "gcr.io/octo-dataplane",
},
goldenFile: "install-control-plane.registry.golden.yaml",
}),
Entry("should generate Kubernetes resources with CNI plugin", testCase{
extraArgs: []string{
"--cni-enabled",
Expand Down
24 changes: 19 additions & 5 deletions app/kumactl/cmd/install/render_helm_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,37 @@ func generateOverrideValues(args interface{}, helmValuesPrefix string) map[strin
t := v.Type()
for i := 0; i < t.NumField(); i++ {
name := t.Field(i).Name
value := v.FieldByName(name).Interface()
value := v.FieldByName(name)
tag := t.Field(i).Tag.Get("helm")

splitTag := strings.Split(tag, ".")
tagCount := len(splitTag)
splitTag := strings.Split(tag, ",")
if len(splitTag) == 0 {
continue
}

var omitEmpty bool
for _, tagSplit := range splitTag[0:] {
omitEmpty = omitEmpty || tagSplit == "omitempty"
}

if omitEmpty && value.IsZero() {
continue
}

valuePath := strings.Split(splitTag[0], ".")
tagCount := len(valuePath)

root := overrideValues

for i := 0; i < tagCount-1; i++ {
n := splitTag[i]
n := valuePath[i]

if _, ok := root[n]; !ok {
root[n] = map[string]interface{}{}
}
root = root[n].(map[string]interface{})
}
root[splitTag[tagCount-1]] = adjustType(value)
root[valuePath[tagCount-1]] = adjustType(value.Interface())
}

if helmValuesPrefix != "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ cni:

image:
# -- CNI image registry
registry: "docker.io"
registry: "docker.io/kumahq"
# -- CNI image repository
repository: "kumahq/install-cni"
repository: "install-cni"
# -- CNI image tag
tag: "0.0.10"

Expand Down
Loading