Skip to content

Commit

Permalink
chore(k8s): always inject Kuma as the first container
Browse files Browse the repository at this point in the history
Signed-off-by: c <curtis@commonstock.com>
  • Loading branch information
curtiscook committed Dec 9, 2022
1 parent e8e08b7 commit b5c37fe
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 33 deletions.
3 changes: 3 additions & 0 deletions api/mesh/v1alpha1/gateway_route.pb.go

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

21 changes: 14 additions & 7 deletions api/mesh/v1alpha1/health_check.pb.go

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

3 changes: 3 additions & 0 deletions api/mesh/v1alpha1/kds.pb.go

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

1 change: 1 addition & 0 deletions api/mesh/v1alpha1/mux.pb.go

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

2 changes: 2 additions & 0 deletions api/mesh/v1alpha1/proxy_template.pb.go

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

28 changes: 14 additions & 14 deletions api/mesh/v1alpha1/retry.pb.go

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

4 changes: 4 additions & 0 deletions api/mesh/v1alpha1/traffic_route.pb.go

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

7 changes: 4 additions & 3 deletions api/observability/v1/mads.pb.go

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

1 change: 1 addition & 0 deletions api/system/v1alpha1/datasource.pb.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/kumahq/kuma/pkg/plugins/policies/validation"
)

//go:embed schema.yaml
// go:embed schema.yaml
var rawSchema []byte
var schema = spec.Schema{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/kumahq/kuma/pkg/plugins/policies/validation"
)

//go:embed schema.yaml
// go:embed schema.yaml
var rawSchema []byte
var schema = spec.Schema{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/kumahq/kuma/pkg/plugins/policies/validation"
)

//go:embed schema.yaml
// go:embed schema.yaml
var rawSchema []byte
var schema = spec.Schema{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/kumahq/kuma/pkg/plugins/policies/validation"
)

//go:embed schema.yaml
// go:embed schema.yaml
var rawSchema []byte
var schema = spec.Schema{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/kumahq/kuma/pkg/plugins/policies/validation"
)

//go:embed schema.yaml
// go:embed schema.yaml
var rawSchema []byte
var schema = spec.Schema{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/kumahq/kuma/pkg/plugins/policies/validation"
)

//go:embed schema.yaml
// go:embed schema.yaml
var rawSchema []byte
var schema = spec.Schema{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ var ALLOW Action = "ALLOW"
var DENY Action = "DENY"

// ALLOW_WITH_SHADOW_DENY action lets the requests pass but emits logs as if
// requests are denied
//
// requests are denied
var ALLOW_WITH_SHADOW_DENY Action = "ALLOW_WITH_SHADOW_DENY"

type Conf struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/kumahq/kuma/pkg/plugins/policies/validation"
)

//go:embed schema.yaml
// go:embed schema.yaml
var rawSchema []byte
var schema = spec.Schema{}

Expand Down
4 changes: 3 additions & 1 deletion pkg/plugins/runtime/k8s/webhooks/injector/injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ func (i *KumaInjector) InjectKuma(ctx context.Context, pod *kube_core.Pod) error
if err != nil {
return err
}
pod.Spec.Containers = append(pod.Spec.Containers, patchedContainer)

// inject sidecar as first container
pod.Spec.Containers = append([]kube_core.Container{patchedContainer}, pod.Spec.Containers...)

// annotations
if pod.Annotations == nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/plugins/runtime/k8s/webhooks/injector/injector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
conf "github.com/kumahq/kuma/pkg/config/plugins/runtime/k8s"
"github.com/kumahq/kuma/pkg/plugins/resources/k8s"
"github.com/kumahq/kuma/pkg/plugins/resources/k8s/native/api/v1alpha1"
k8s_util "github.com/kumahq/kuma/pkg/plugins/runtime/k8s/util"
inject "github.com/kumahq/kuma/pkg/plugins/runtime/k8s/webhooks/injector"
"github.com/kumahq/kuma/pkg/test/matchers"
)
Expand Down Expand Up @@ -117,6 +118,7 @@ spec:
err = injector.InjectKuma(context.Background(), pod)
// then
Expect(err).ToNot(HaveOccurred())
Expect(pod.Spec.Containers[0].Name).To(BeEquivalentTo(k8s_util.KumaSidecarContainerName))

By("loading golden Pod")
// when
Expand Down

0 comments on commit b5c37fe

Please sign in to comment.