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

[Backport release-1.27] Only include envoy image in default config if images should be included #3668

Merged
merged 1 commit into from
Nov 2, 2023
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
1 change: 1 addition & 0 deletions cmd/config/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func NewCreateCmd() *cobra.Command {
config := v1beta1.DefaultClusterConfig()
if !includeImages {
config.Spec.Images = nil
config.Spec.Network.NodeLocalLoadBalancing.EnvoyProxy.Image = nil
}

cfg, err := yaml.Marshal(config)
Expand Down
65 changes: 65 additions & 0 deletions cmd/config/create_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
Copyright 2023 k0s authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package config_test

import (
"strings"
"testing"

"github.com/stretchr/testify/assert"

"github.com/k0sproject/k0s/cmd/config"
)

func TestCreateCmd_Images(t *testing.T) {
for _, test := range []struct {
name string
args []string
check func(t *testing.T, cfg, needle string)
}{
{
"default", []string{},
func(t *testing.T, cfg, needle string) { t.Helper(); assert.NotContains(t, cfg, needle) },
},

{
"include_images", []string{"--include-images"},
func(t *testing.T, cfg, needle string) { t.Helper(); assert.Contains(t, cfg, needle) },
},
} {
t.Run(test.name, func(t *testing.T) {
underTest := config.NewCreateCmd()

var out strings.Builder
var err strings.Builder
underTest.SetArgs(test.args)
underTest.SetOut(&out)
underTest.SetErr(&err)

assert.NoError(t, underTest.Execute())

assert.Empty(t, err.String(), "Something has been written to stderr")
// This is a very broad check if there's some ImageSpec in the output. May
// produce false positives if something similar gets added to the config in
// the future. Can be refined then.
cfg := out.String()
test.check(t, cfg, "quay.io/k0sproject")
test.check(t, cfg, "image: ")
test.check(t, cfg, "version: ")
})
}
}
3 changes: 0 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ spec:
enabled: false
envoyProxy:
apiServerBindPort: 7443
image:
image: docker.io/envoyproxy/envoy-distroless
version: v1.24.1
konnectivityServerBindPort: 7132
type: EnvoyProxy
podCIDR: 10.244.0.0/16
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/k0s.k0sproject.io/v1beta1/nllb.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (n *NodeLocalLoadBalancing) IsEnabled() bool {
type EnvoyProxy struct {
// image specifies the OCI image that's being used for the Envoy Pod.
// +optional
Image *ImageSpec `json:"image"`
Image *ImageSpec `json:"image,omitempty"`

// imagePullPolicy specifies the pull policy being used for the Envoy Pod.
// Defaults to the default image pull policy.
Expand Down
Loading