Skip to content

Commit

Permalink
feat(kumactl) add --use-node-port to install ingress (#856)
Browse files Browse the repository at this point in the history
Add `kumactl install ingress --use-node-port` and default to using LoadBalancer in the Ingress service, when this flag is not set.

Signed-off-by: Nikolay Nikolaev <[email protected]>
  • Loading branch information
Nikolay Nikolaev authored Jun 26, 2020
1 parent 8339fcb commit 7ee2113
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions app/kumactl/cmd/completion/testdata/bash.golden
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,8 @@ _kumactl_install_ingress()
flags+=("--namespace=")
two_word_flags+=("--namespace")
local_nonpersistent_flags+=("--namespace=")
flags+=("--use-node-port")
local_nonpersistent_flags+=("--use-node-port")
flags+=("--version=")
two_word_flags+=("--version")
local_nonpersistent_flags+=("--version=")
Expand Down
1 change: 1 addition & 0 deletions app/kumactl/cmd/completion/testdata/zsh.golden
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ function _kumactl_install_ingress {
'--image-pull-policy[image pull policy for Ingress]:' \
'--kuma-cp-address[the address of Kuma CP]:' \
'--namespace[namespace to install Ingress to]:' \
'--use-node-port[use NodePort instead of LoadBalancer]' \
'--version[version of Ingress component]:' \
'--config-file[path to the configuration file to use]:' \
'--log-level[log level: one of off|info|debug]:' \
Expand Down
7 changes: 7 additions & 0 deletions app/kumactl/cmd/install/install_ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func newInstallIngressCmd() *cobra.Command {
Mesh string
DrainTime string
KumaCpAddress string
IngressPortType string
}{
Namespace: "kuma-system",
Image: "kong-docker-kuma-docker.bintray.io/kuma-dp",
Expand All @@ -27,12 +28,17 @@ func newInstallIngressCmd() *cobra.Command {
Mesh: "default",
DrainTime: "30s",
KumaCpAddress: "http://kuma-control-plane.kuma-system:5681",
IngressPortType: "LoadBalancer",
}
useNodePort := false
cmd := &cobra.Command{
Use: "ingress",
Short: "Install Ingress on Kubernetes",
Long: `Install Ingress on Kubernetes in a 'kuma-system' namespace.`,
RunE: func(cmd *cobra.Command, _ []string) error {
if useNodePort {
args.IngressPortType = "NodePort"
}
templateFiles, err := data.ReadFiles(ingress.Templates)
if err != nil {
return errors.Wrap(err, "Failed to read template files")
Expand Down Expand Up @@ -61,5 +67,6 @@ func newInstallIngressCmd() *cobra.Command {
cmd.Flags().StringVar(&args.Mesh, "mesh", args.Mesh, "mesh for Ingress")
cmd.Flags().StringVar(&args.DrainTime, "drain-time", args.DrainTime, "drain time for Envoy proxy")
cmd.Flags().StringVar(&args.KumaCpAddress, "kuma-cp-address", args.KumaCpAddress, "the address of Kuma CP")
cmd.Flags().BoolVar(&useNodePort, "use-node-port", false, "use NodePort instead of LoadBalancer")
return cmd
}
1 change: 1 addition & 0 deletions app/kumactl/cmd/install/install_ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ var _ = Describe("kumactl install ingress", func() {
"--kuma-cp-address", "http://kuma.local:5681",
"--mesh", "non-default-mesh",
"--drain-time", "0s",
"--use-node-port",
},
goldenFile: "install-ingress.overrides.golden.yaml",
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ metadata:
name: kuma-ingress
namespace: kuma-system
spec:
type: NodePort
type: LoadBalancer
ports:
- port: 10001
protocol: TCP
Expand Down
2 changes: 1 addition & 1 deletion app/kumactl/data/install/k8s/ingress/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ metadata:
name: kuma-ingress
namespace: {{ .Namespace }}
spec:
type: NodePort
type: {{ .IngressPortType }}
ports:
- port: 10001
protocol: TCP
Expand Down
8 changes: 4 additions & 4 deletions app/kumactl/pkg/install/k8s/ingress/templates_vfsdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/framework/kumactl.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ func (o *KumactlOptions) KumactlInstallIngress() (string, error) {
args := []string{
"install", "ingress",
"--image", kumaDPImage,
"--use-node-port",
}
return o.RunKumactlAndGetOutput(args...)
}
Expand Down

0 comments on commit 7ee2113

Please sign in to comment.