Skip to content

Commit

Permalink
refactor: Write configuration under /etc/caren
Browse files Browse the repository at this point in the history
Previously, we wrote some configuration to /etc/cre. Now that the
project name is CAREN, we should use /etc/caren.

We also wrote containerd configuration to /etc/containerd/cre.d, but
this configuration is not read by containerd directly. Instead, it is
read by a script that merges it to the primary containerd configuration.
For that reason, this configuration belongs under /etc/caren.
  • Loading branch information
dlipovetsky committed May 13, 2024
1 parent 22bf205 commit f90bcaf
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pkg/handlers/generic/mutation/containerdmetrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

const (
// TODO Factor out this constant to a common package.
containerdPatchesDirOnRemote = "/etc/containerd/cre.d"
containerdPatchesDirOnRemote = "/etc/caren/containerd"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

const (
//nolint:gosec // Does not contain hard coded credentials.
installKubeletCredentialProvidersScriptOnRemote = "/etc/cre/install-kubelet-credential-providers.sh"
installKubeletCredentialProvidersScriptOnRemote = "/etc/caren/install-kubelet-credential-providers.sh"

installKubeletCredentialProvidersScriptOnRemoteCommand = "/bin/bash " + installKubeletCredentialProvidersScriptOnRemote

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ var _ = Describe("Generate Image registry patches", func() {
Path: "/spec/template/spec/kubeadmConfigSpec/files",
ValueMatcher: gomega.ContainElements(
gomega.HaveKeyWithValue(
"path", "/etc/cre/install-kubelet-credential-providers.sh",
"path", "/etc/caren/install-kubelet-credential-providers.sh",
),
gomega.HaveKeyWithValue(
"path", "/etc/kubernetes/image-credential-provider-config.yaml",
Expand All @@ -175,7 +175,7 @@ var _ = Describe("Generate Image registry patches", func() {
Operation: "add",
Path: "/spec/template/spec/kubeadmConfigSpec/preKubeadmCommands",
ValueMatcher: gomega.ContainElement(
"/bin/bash /etc/cre/install-kubelet-credential-providers.sh",
"/bin/bash /etc/caren/install-kubelet-credential-providers.sh",
),
},
{
Expand Down Expand Up @@ -222,7 +222,7 @@ var _ = Describe("Generate Image registry patches", func() {
Path: "/spec/template/spec/kubeadmConfigSpec/files",
ValueMatcher: gomega.ContainElements(
gomega.HaveKeyWithValue(
"path", "/etc/cre/install-kubelet-credential-providers.sh",
"path", "/etc/caren/install-kubelet-credential-providers.sh",
),
gomega.HaveKeyWithValue(
"path", "/etc/kubernetes/image-credential-provider-config.yaml",
Expand All @@ -239,7 +239,7 @@ var _ = Describe("Generate Image registry patches", func() {
Operation: "add",
Path: "/spec/template/spec/kubeadmConfigSpec/preKubeadmCommands",
ValueMatcher: gomega.ContainElement(
"/bin/bash /etc/cre/install-kubelet-credential-providers.sh",
"/bin/bash /etc/caren/install-kubelet-credential-providers.sh",
),
},
{
Expand Down Expand Up @@ -286,7 +286,7 @@ var _ = Describe("Generate Image registry patches", func() {
Path: "/spec/template/spec/files",
ValueMatcher: gomega.ContainElements(
gomega.HaveKeyWithValue(
"path", "/etc/cre/install-kubelet-credential-providers.sh",
"path", "/etc/caren/install-kubelet-credential-providers.sh",
),
gomega.HaveKeyWithValue(
"path", "/etc/kubernetes/image-credential-provider-config.yaml",
Expand All @@ -300,7 +300,7 @@ var _ = Describe("Generate Image registry patches", func() {
Operation: "add",
Path: "/spec/template/spec/preKubeadmCommands",
ValueMatcher: gomega.ContainElement(
"/bin/bash /etc/cre/install-kubelet-credential-providers.sh",
"/bin/bash /etc/caren/install-kubelet-credential-providers.sh",
),
},
{
Expand Down Expand Up @@ -344,7 +344,7 @@ var _ = Describe("Generate Image registry patches", func() {
Path: "/spec/template/spec/files",
ValueMatcher: gomega.ContainElements(
gomega.HaveKeyWithValue(
"path", "/etc/cre/install-kubelet-credential-providers.sh",
"path", "/etc/caren/install-kubelet-credential-providers.sh",
),
gomega.HaveKeyWithValue(
"path", "/etc/kubernetes/image-credential-provider-config.yaml",
Expand All @@ -361,7 +361,7 @@ var _ = Describe("Generate Image registry patches", func() {
Operation: "add",
Path: "/spec/template/spec/preKubeadmCommands",
ValueMatcher: gomega.ContainElement(
"/bin/bash /etc/cre/install-kubelet-credential-providers.sh",
"/bin/bash /etc/caren/install-kubelet-credential-providers.sh",
),
},
{
Expand Down
8 changes: 4 additions & 4 deletions pkg/handlers/generic/mutation/mirrors/inject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var _ = Describe("Generate Global mirror patches", func() {
"path", "/etc/containerd/certs.d/_default/hosts.toml",
),
gomega.HaveKeyWithValue(
"path", "/etc/containerd/cre.d/registry-config.toml",
"path", "/etc/caren/containerd/registry-config.toml",
),
gomega.HaveKeyWithValue(
"path", "/etc/containerd/apply-patches.sh",
Expand Down Expand Up @@ -115,7 +115,7 @@ var _ = Describe("Generate Global mirror patches", func() {
"path", "/etc/certs/mirror.pem",
),
gomega.HaveKeyWithValue(
"path", "/etc/containerd/cre.d/registry-config.toml",
"path", "/etc/caren/containerd/registry-config.toml",
),
gomega.HaveKeyWithValue(
"path", "/etc/containerd/apply-patches.sh",
Expand Down Expand Up @@ -160,7 +160,7 @@ var _ = Describe("Generate Global mirror patches", func() {
"path", "/etc/containerd/certs.d/_default/hosts.toml",
),
gomega.HaveKeyWithValue(
"path", "/etc/containerd/cre.d/registry-config.toml",
"path", "/etc/caren/containerd/registry-config.toml",
),
gomega.HaveKeyWithValue(
"path", "/etc/containerd/apply-patches.sh",
Expand Down Expand Up @@ -213,7 +213,7 @@ var _ = Describe("Generate Global mirror patches", func() {
"path", "/etc/certs/mirror.pem",
),
gomega.HaveKeyWithValue(
"path", "/etc/containerd/cre.d/registry-config.toml",
"path", "/etc/caren/containerd/registry-config.toml",
),
gomega.HaveKeyWithValue(
"path", "/etc/containerd/apply-patches.sh",
Expand Down
2 changes: 1 addition & 1 deletion pkg/handlers/generic/mutation/mirrors/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
secretKeyForMirrorCACert = "ca.crt"

tomlMergeImage = "ghcr.io/mesosphere/toml-merge:v0.2.0"
containerdPatchesDirOnRemote = "/etc/containerd/cre.d"
containerdPatchesDirOnRemote = "/etc/caren/containerd"
containerdApplyPatchesScriptOnRemote = "/etc/containerd/apply-patches.sh"
containerdApplyPatchesScriptOnRemoteCommand = "/bin/bash " + containerdApplyPatchesScriptOnRemote
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/handlers/generic/mutation/mirrors/mirror_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func Test_generateMirrorCACertFile(t *testing.T) {
func Test_generateContainerdRegistryConfigDropInFile(t *testing.T) {
want := []cabpkv1.File{
{
Path: "/etc/containerd/cre.d/registry-config.toml",
Path: "/etc/caren/containerd/registry-config.toml",
Owner: "",
Permissions: "0600",
Encoding: "",
Expand Down Expand Up @@ -203,7 +203,7 @@ trap 'cleanup' EXIT
readonly tmp_ctr_mount_dir="$(mktemp -d)"
ctr --namespace k8s.io images mount "${TOML_MERGE_IMAGE}" "${tmp_ctr_mount_dir}"
"${tmp_ctr_mount_dir}/usr/local/bin/toml-merge" -i --patch-file "/etc/containerd/cre.d/*.toml" /etc/containerd/config.toml
"${tmp_ctr_mount_dir}/usr/local/bin/toml-merge" -i --patch-file "/etc/caren/containerd/*.toml" /etc/containerd/config.toml
`,
},
}
Expand Down

0 comments on commit f90bcaf

Please sign in to comment.