Skip to content

Commit

Permalink
Merge pull request #3776 from arghya88/remove-tmp
Browse files Browse the repository at this point in the history
⚠️capk generates kubadm config files under /run/kubeadm/ instead of /tmp
  • Loading branch information
k8s-ci-robot authored Oct 15, 2020
2 parents 6404141 + 8357d55 commit c60ae8b
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bootstrap/kubeadm/internal/cloudinit/cloudinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

const (
standardJoinCommand = "kubeadm join --config /tmp/kubeadm-join-config.yaml %s"
standardJoinCommand = "kubeadm join --config /run/kubeadm/kubeadm-join-config.yaml %s"
retriableJoinScriptName = "/usr/local/bin/kubeadm-bootstrap-script"
retriableJoinScriptOwner = "root"
retriableJoinScriptPermissions = "0755"
Expand Down
4 changes: 2 additions & 2 deletions bootstrap/kubeadm/internal/cloudinit/controlplane_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
const (
controlPlaneCloudInit = `{{.Header}}
{{template "files" .WriteFiles}}
- path: /tmp/kubeadm.yaml
- path: /run/kubeadm/kubeadm.yaml
owner: root:root
permissions: '0640'
content: |
Expand All @@ -33,7 +33,7 @@ const (
{{.InitConfiguration | Indent 6}}
runcmd:
{{- template "commands" .PreKubeadmCommands }}
- 'kubeadm init --config /tmp/kubeadm.yaml {{.KubeadmVerbosity}}'
- 'kubeadm init --config /run/kubeadm/kubeadm.yaml {{.KubeadmVerbosity}}'
{{- template "commands" .PostKubeadmCommands }}
{{- template "ntp" .NTP }}
{{- template "users" .Users }}
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/kubeadm/internal/cloudinit/controlplane_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
const (
controlPlaneJoinCloudInit = `{{.Header}}
{{template "files" .WriteFiles}}
- path: /tmp/kubeadm-join-config.yaml
- path: /run/kubeadm/kubeadm-join-config.yaml
owner: root:root
permissions: '0640'
content: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function retry-command() {
until [ $n -ge 5 ]; do
log::info "running '$*'"
# shellcheck disable=SC1083
"$@" --config=/tmp/kubeadm-join-config.yaml {{.KubeadmVerbosity}}
"$@" --config=/run/kubeadm/kubeadm-join-config.yaml {{.KubeadmVerbosity}}
kubeadm_return=$?
check_kubeadm_command "'$*'" "${kubeadm_return}"
if [ ${kubeadm_return} -eq 0 ]; then
Expand All @@ -111,7 +111,7 @@ function try-or-die-command() {
local kubeadm_return
log::info "running '$*'"
# shellcheck disable=SC1083
"$@" --config=/tmp/kubeadm-join-config.yaml {{.KubeadmVerbosity}}
"$@" --config=/run/kubeadm/kubeadm-join-config.yaml {{.KubeadmVerbosity}}
kubeadm_return=$?
check_kubeadm_command "'$*'" "${kubeadm_return}"
if [ ${kubeadm_return} -ne 0 ]; then
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/kubeadm/internal/cloudinit/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package cloudinit
const (
nodeCloudInit = `{{.Header}}
{{template "files" .WriteFiles}}
- path: /tmp/kubeadm-join-config.yaml
- path: /run/kubeadm/kubeadm-join-config.yaml
owner: root:root
permissions: '0640'
content: |
Expand Down
4 changes: 2 additions & 2 deletions bootstrap/kubeadm/internal/cloudinit/zz_generated.bindata.go

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

10 changes: 5 additions & 5 deletions test/infrastructure/docker/cloudinit/kindadapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ write_files:
\ 0\nnodeRegistration:\n criSocket: /var/run/containerd/containerd.sock\n\
\ kubeletExtraArgs:\n cloud-provider: aws\n name: 'ip-10-0-0-223.us-west-2.compute.internal'\n"
owner: root:root
path: /tmp/kubeadm.yaml
path: /run/kubeadm/kubeadm.yaml
permissions: '0640'
`)

Expand Down Expand Up @@ -133,10 +133,10 @@ write_files:
{Cmd: "mkdir", Args: []string{"-p", "/etc/kubernetes/pki"}},
{Cmd: "/bin/sh", Args: []string{"-c", "cat > /etc/kubernetes/pki/sa.key /dev/stdin"}},
{Cmd: "chmod", Args: []string{"0600", "/etc/kubernetes/pki/sa.key"}},
// /tmp/kubeadm.yaml
{Cmd: "mkdir", Args: []string{"-p", "/tmp"}},
{Cmd: "/bin/sh", Args: []string{"-c", "cat > /tmp/kubeadm.yaml /dev/stdin"}},
{Cmd: "chmod", Args: []string{"0640", "/tmp/kubeadm.yaml"}},
// /run/kubeadm/kubeadm.yaml
{Cmd: "mkdir", Args: []string{"-p", "/run/kubeadm"}},
{Cmd: "/bin/sh", Args: []string{"-c", "cat > /run/kubeadm/kubeadm.yaml /dev/stdin"}},
{Cmd: "chmod", Args: []string{"0640", "/run/kubeadm/kubeadm.yaml"}},
}

commands, err := Commands(cloudData)
Expand Down
12 changes: 6 additions & 6 deletions test/infrastructure/docker/cloudinit/runcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ func TestRunCmdRun(t *testing.T) {
name: "hack kubeadm ingore errors",
r: runCmd{
Cmds: []Cmd{
{Cmd: "/bin/sh", Args: []string{"-c", "kubeadm init --config /tmp/kubeadm.yaml"}},
{Cmd: "/bin/sh", Args: []string{"-c", "kubeadm init --config /run/kubeadm/kubeadm.yaml"}},
},
},
expectedCmds: []Cmd{
{Cmd: "/bin/sh", Args: []string{"-c", "kubeadm init --config /tmp/kubeadm.yaml --ignore-preflight-errors=all"}},
{Cmd: "/bin/sh", Args: []string{"-c", "kubeadm init --config /run/kubeadm/kubeadm.yaml --ignore-preflight-errors=all"}},
},
},
}
Expand All @@ -89,20 +89,20 @@ func TestHackKubeadmIgnoreErrors(t *testing.T) {

cloudData := `
runcmd:
- kubeadm init --config=/tmp/kubeadm.yaml
- [ kubeadm, join, --config=/tmp/kubeadm-controlplane-join-config.yaml ]`
- kubeadm init --config=/run/kubeadm/kubeadm.yaml
- [ kubeadm, join, --config=/run/kubeadm/kubeadm-controlplane-join-config.yaml ]`
r := runCmd{}
err := r.Unmarshal([]byte(cloudData))
g.Expect(err).NotTo(HaveOccurred())
g.Expect(r.Cmds).To(HaveLen(2))

r.Cmds[0] = hackKubeadmIgnoreErrors(r.Cmds[0])

expected0 := Cmd{Cmd: "/bin/sh", Args: []string{"-c", "kubeadm init --config=/tmp/kubeadm.yaml --ignore-preflight-errors=all"}}
expected0 := Cmd{Cmd: "/bin/sh", Args: []string{"-c", "kubeadm init --config=/run/kubeadm/kubeadm.yaml --ignore-preflight-errors=all"}}
g.Expect(r.Cmds[0]).To(Equal(expected0))

r.Cmds[1] = hackKubeadmIgnoreErrors(r.Cmds[1])

expected1 := Cmd{Cmd: "kubeadm", Args: []string{"join", "--config=/tmp/kubeadm-controlplane-join-config.yaml", "--ignore-preflight-errors=all"}}
expected1 := Cmd{Cmd: "kubeadm", Args: []string{"join", "--config=/run/kubeadm/kubeadm-controlplane-join-config.yaml", "--ignore-preflight-errors=all"}}
g.Expect(r.Cmds[1]).To(Equal(expected1))
}

0 comments on commit c60ae8b

Please sign in to comment.