Skip to content

Commit

Permalink
feat(*): enable Gateway with runtime flag (#3736)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
  • Loading branch information
jakubdyszkiewicz authored Jan 25, 2022
1 parent 95ae5bf commit d259a13
Show file tree
Hide file tree
Showing 56 changed files with 1,966 additions and 1,315 deletions.
3 changes: 3 additions & 0 deletions app/kumactl/cmd/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
rest_types "github.com/kumahq/kuma/pkg/core/resources/model/rest"
"github.com/kumahq/kuma/pkg/core/resources/registry"
"github.com/kumahq/kuma/pkg/core/resources/store"
"github.com/kumahq/kuma/pkg/plugins/runtime/gateway/register"
"github.com/kumahq/kuma/pkg/util/template"
)

Expand All @@ -39,6 +40,8 @@ type applyContext struct {
}

func NewApplyCmd(pctx *kumactl_cmd.RootContext) *cobra.Command {
register.RegisterGatewayTypes() // allow applying experimental Gateway types

ctx := &applyContext{RootContext: pctx}
cmd := &cobra.Command{
Use: "apply",
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 @@ -2984,6 +2984,8 @@ _kumactl_install_control-plane()
two_word_flags+=("--env-var")
local_nonpersistent_flags+=("--env-var")
local_nonpersistent_flags+=("--env-var=")
flags+=("--experimental-gateway")
local_nonpersistent_flags+=("--experimental-gateway")
flags+=("--image-pull-policy=")
two_word_flags+=("--image-pull-policy")
local_nonpersistent_flags+=("--image-pull-policy")
Expand Down Expand Up @@ -3082,6 +3084,8 @@ _kumactl_install_crds()
flags_with_completion=()
flags_completion=()

flags+=("--experimental-gateway")
local_nonpersistent_flags+=("--experimental-gateway")
flags+=("--only-missing")
local_nonpersistent_flags+=("--only-missing")
flags+=("--api-timeout=")
Expand Down
3 changes: 3 additions & 0 deletions app/kumactl/cmd/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ import (
kumactl_cmd "github.com/kumahq/kuma/app/kumactl/pkg/cmd"
"github.com/kumahq/kuma/pkg/core/resources/model"
"github.com/kumahq/kuma/pkg/core/resources/store"
"github.com/kumahq/kuma/pkg/plugins/runtime/gateway/register"
)

func NewDeleteCmd(pctx *kumactl_cmd.RootContext) *cobra.Command {
register.RegisterGatewayTypes() // allow applying experimental Gateway types

byName := map[string]model.ResourceTypeDescriptor{}
allNames := []string{}
for _, desc := range pctx.Runtime.Registry.ObjectDescriptors(model.HasKumactlEnabled()) {
Expand Down
3 changes: 3 additions & 0 deletions app/kumactl/cmd/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import (
"github.com/kumahq/kuma/app/kumactl/pkg/output"
kuma_cmd "github.com/kumahq/kuma/pkg/cmd"
"github.com/kumahq/kuma/pkg/core/resources/model"
"github.com/kumahq/kuma/pkg/plugins/runtime/gateway/register"
)

func NewGetCmd(pctx *kumactl_cmd.RootContext) *cobra.Command {
register.RegisterGatewayTypes() // allow applying experimental Gateway types

getCmd := &cobra.Command{
Use: "get",
Short: "Show Kuma resources",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type InstallControlPlaneArgs struct {
Ingress_drainTime string `helm:"ingress.drainTime"`
Ingress_service_type string `helm:"ingress.service.type"`
WithoutKubernetesConnection bool // there is no HELM equivalent, HELM always require connection to Kubernetes
ExperimentalGateway bool `helm:"experimental.gateway"`
}

type ImageEnvSecret struct {
Expand Down
3 changes: 2 additions & 1 deletion app/kumactl/cmd/install/context/install_crds_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
)

type InstallCrdsArgs struct {
OnlyMissing bool
OnlyMissing bool
ExperimentalGateway bool
}

type InstallCrdsContext struct {
Expand Down
8 changes: 8 additions & 0 deletions app/kumactl/cmd/install/install_control_plane.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
kuma_cmd "github.com/kumahq/kuma/pkg/cmd"
"github.com/kumahq/kuma/pkg/config/core"
bootstrap_k8s "github.com/kumahq/kuma/pkg/plugins/bootstrap/k8s"
mesh_k8s "github.com/kumahq/kuma/pkg/plugins/resources/k8s/native/api/v1alpha1"
"github.com/kumahq/kuma/pkg/plugins/runtime/gateway/register"
)

type componentVersion struct {
Expand Down Expand Up @@ -51,6 +53,11 @@ This command requires that the KUBECONFIG environment is set`,
return err
}

if args.ExperimentalGateway {
register.RegisterGatewayTypes()
mesh_k8s.RegisterK8SGatewayTypes()
}

if useNodePort && args.ControlPlane_mode == core.Global {
args.ControlPlane_globalZoneSyncService_type = "NodePort"
}
Expand Down Expand Up @@ -143,6 +150,7 @@ This command requires that the KUBECONFIG environment is set`,
cmd.Flags().StringVar(&args.Ingress_drainTime, "ingress-drain-time", args.Ingress_drainTime, "drain time for Envoy proxy")
cmd.Flags().BoolVar(&ingressUseNodePort, "ingress-use-node-port", false, "use NodePort instead of LoadBalancer for the Ingress Service")
cmd.Flags().BoolVar(&args.WithoutKubernetesConnection, "without-kubernetes-connection", false, "install without connection to Kubernetes cluster. This can be used for initial Kuma installation, but not for upgrades")
cmd.Flags().BoolVar(&args.ExperimentalGateway, "experimental-gateway", false, "install experimental built-in Gateway support")
return cmd
}

Expand Down
1 change: 1 addition & 0 deletions app/kumactl/cmd/install/install_control_plane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ var _ = Describe("kumactl install control-plane", func() {
"--zone", "zone-1",
"--use-node-port",
"--without-kubernetes-connection",
"--experimental-gateway",
},
goldenFile: "install-control-plane.overrides.golden.yaml",
}),
Expand Down
8 changes: 8 additions & 0 deletions app/kumactl/cmd/install/install_crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"github.com/kumahq/kuma/app/kumactl/pkg/install/data"
"github.com/kumahq/kuma/app/kumactl/pkg/install/k8s"
bootstrap_k8s "github.com/kumahq/kuma/pkg/plugins/bootstrap/k8s"
mesh_k8s "github.com/kumahq/kuma/pkg/plugins/resources/k8s/native/api/v1alpha1"
"github.com/kumahq/kuma/pkg/plugins/runtime/gateway/register"
)

func newInstallCrdsCmd(ctx *install_context.InstallCrdsContext) *cobra.Command {
Expand All @@ -23,6 +25,11 @@ func newInstallCrdsCmd(ctx *install_context.InstallCrdsContext) *cobra.Command {
Use: "crds",
Short: "Install Kuma Custom Resource Definitions on Kubernetes",
RunE: func(cmd *cobra.Command, _ []string) error {
if args.ExperimentalGateway {
register.RegisterGatewayTypes()
mesh_k8s.RegisterK8SGatewayTypes()
}

wantCrdFiles, err := ctx.InstallCrdTemplateFiles(args)
if err != nil {
return errors.Wrap(err, "Failed to read CRD files")
Expand Down Expand Up @@ -87,6 +94,7 @@ func newInstallCrdsCmd(ctx *install_context.InstallCrdsContext) *cobra.Command {
}

cmd.Flags().BoolVar(&args.OnlyMissing, "only-missing", false, "install only resources which are not already present in a cluster")
cmd.Flags().BoolVar(&args.ExperimentalGateway, "experimental-gateway", false, "install experimental built-in Gateway support")

return cmd
}
Expand Down
4 changes: 4 additions & 0 deletions app/kumactl/cmd/install/install_crds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,9 @@ var _ = Describe("kumactl install crds", func() {
extraArgs: nil,
goldenFile: "install-crds.all.golden.yaml",
}),
Entry("should generate all Kuma's CRD resources including experimental gateway", testCase{
extraArgs: []string{"--experimental-gateway"},
goldenFile: "install-crds.experimental-gateway.golden.yaml",
}),
)
})
Original file line number Diff line number Diff line change
Expand Up @@ -1520,43 +1520,7 @@ rules:
- get
- list
- watch
- apiGroups:
- "apps"
resources:
- deployments
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- gateway.networking.k8s.io
resources:
- gatewayclasses
- gateways
- referencepolicies
- httproutes
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- gateway.networking.k8s.io
resources:
- gatewayclasses/status
- gateways/status
- httproutes/status
verbs:
- get
- patch
- update

- apiGroups:
- coordination.k8s.io
resources:
Expand Down Expand Up @@ -1623,28 +1587,7 @@ rules:
- update
- patch
- delete
- apiGroups:
- kuma.io
resources:
- gateways
- gatewayroutes
- gatewayinstances
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- kuma.io
resources:
- gatewayinstances/status
verbs:
- get
- patch
- update

- apiGroups:
- kuma.io
resources:
Expand Down
Loading

0 comments on commit d259a13

Please sign in to comment.