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

Stop trying to pull the Protokube image #9809

Merged
merged 1 commit into from
Aug 25, 2020
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
33 changes: 1 addition & 32 deletions nodeup/pkg/model/protokube.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ func (t *ProtokubeBuilder) buildSystemdService() (*nodetasks.Service, error) {
return nil, err
}

protokubeImagePullCommand, err := t.ProtokubeImagePullCommand()
if err != nil {
return nil, err
}
protokubeContainerStopCommand, err := t.ProtokubeContainerStopCommand()
if err != nil {
return nil, err
Expand All @@ -143,10 +139,9 @@ func (t *ProtokubeBuilder) buildSystemdService() (*nodetasks.Service, error) {
// @step: let need a dependency for any volumes to be mounted first
manifest.Set("Service", "ExecStartPre", protokubeContainerStopCommand)
manifest.Set("Service", "ExecStartPre", protokubeContainerRemoveCommand)
manifest.Set("Service", "ExecStartPre", protokubeImagePullCommand)
manifest.Set("Service", "ExecStart", protokubeContainerRunCommand+" "+protokubeRunArgs)
manifest.Set("Service", "Restart", "always")
manifest.Set("Service", "RestartSec", "2s")
manifest.Set("Service", "RestartSec", "3s")
manifest.Set("Service", "StartLimitInterval", "0")
manifest.Set("Install", "WantedBy", "multi-user.target")

Expand Down Expand Up @@ -176,32 +171,6 @@ func (t *ProtokubeBuilder) ProtokubeImageName() string {
return name
}

// ProtokubeImagePullCommand returns the command to pull the image
func (t *ProtokubeBuilder) ProtokubeImagePullCommand() (string, error) {
var sources []string
if t.NodeupConfig.ProtokubeImage[t.Architecture] != nil {
sources = t.NodeupConfig.ProtokubeImage[t.Architecture].Sources
}
if len(sources) == 0 {
// Nothing to pull; return dummy value
return "/bin/true", nil
}
if strings.HasPrefix(sources[0], "http:") || strings.HasPrefix(sources[0], "https:") || strings.HasPrefix(sources[0], "s3:") {
// We preloaded the image; return a dummy value
return "/bin/true", nil
}

var protokubeImagePullCommand string
if t.Cluster.Spec.ContainerRuntime == "docker" {
protokubeImagePullCommand = "-/usr/bin/docker pull " + sources[0]
} else if t.Cluster.Spec.ContainerRuntime == "containerd" {
protokubeImagePullCommand = "-/usr/bin/ctr --namespace k8s.io images pull docker.io/" + sources[0]
} else {
return "", fmt.Errorf("unable to create protokube image pull command for unsupported runtime %q", t.Cluster.Spec.ContainerRuntime)
}
return protokubeImagePullCommand, nil
}

// ProtokubeContainerStopCommand returns the command that stops the Protokube container, before being removed
func (t *ProtokubeBuilder) ProtokubeContainerStopCommand() (string, error) {
var containerStopCommand string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ definition: |
[Service]
ExecStartPre=/bin/true
ExecStartPre=-/usr/bin/ctr --namespace k8s.io container rm protokube
ExecStartPre=/bin/true
ExecStart=/usr/bin/ctr --namespace k8s.io run --net-host --with-ns pid:/proc/1/ns/pid --privileged --mount type=bind,src=/,dst=/rootfs,options=rbind:rslave --env KUBECONFIG=/rootfs/var/lib/kops/kubeconfig --mount type=bind,src=/bin,dst=/bin,options=rbind:ro:rprivate --mount type=bind,src=/lib,dst=/lib,options=rbind:ro:rprivate --mount type=bind,src=/lib64,dst=/lib64,options=rbind:ro:rprivate --mount type=bind,src=/sbin,dst=/sbin,options=rbind:ro:rprivate --mount type=bind,src=/usr/bin,dst=/usr/bin,options=rbind:ro:rprivate --mount type=bind,src=/var/run/dbus,dst=/var/run/dbus,options=rbind:rprivate --mount type=bind,src=/run/systemd,dst=/run/systemd,options=rbind:rprivate --mount type=bind,src=/usr/local/bin,dst=/opt/kops/bin,options=rbind:ro:rprivate --env PATH=/opt/kops/bin:/usr/bin:/sbin:/bin docker.io/library/protokube image name protokube /protokube --bootstrap-master-node-labels=true --cloud=aws --containerized=true --dns-internal-suffix=.internal.minimal.example.com --dns=aws-route53 --etcd-backup-store=memfs://clusters.example.com/minimal.example.com/backups/etcd/main --etcd-image=k8s.gcr.io/etcd:3.4.3 --initialize-rbac=true --manage-etcd=true --master=true --node-name=master.hostname.invalid --peer-ca=/srv/kubernetes/ca.crt --peer-cert=/srv/kubernetes/etcd-peer.pem --peer-key=/srv/kubernetes/etcd-peer-key.pem --tls-auth=true --tls-ca=/srv/kubernetes/ca.crt --tls-cert=/srv/kubernetes/etcd.pem --tls-key=/srv/kubernetes/etcd-key.pem --v=4 --zone=*/Z1AFAKE1ZON3YO
Restart=always
RestartSec=2s
RestartSec=3s
StartLimitInterval=0

[Install]
Expand Down
3 changes: 1 addition & 2 deletions nodeup/pkg/model/tests/protokube/docker/tasks-protokube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ definition: |
[Service]
ExecStartPre=-/usr/bin/docker stop protokube
ExecStartPre=-/usr/bin/docker rm protokube
ExecStartPre=/bin/true
ExecStart=/usr/bin/docker run --net=host --pid=host --privileged --volume /:/rootfs --env KUBECONFIG=/rootfs/var/lib/kops/kubeconfig --volume /bin:/bin:ro --volume /lib:/lib:ro --volume /lib64:/lib64:ro --volume /sbin:/sbin:ro --volume /usr/bin:/usr/bin:ro --volume /var/run/dbus:/var/run/dbus --volume /run/systemd:/run/systemd --volume /usr/local/bin:/opt/kops/bin:ro --env PATH=/opt/kops/bin:/usr/bin:/sbin:/bin --name protokube protokube image name /protokube --bootstrap-master-node-labels=true --cloud=aws --containerized=true --dns-internal-suffix=internal.minimal.k8s.local --dns=gossip --etcd-backup-store=memfs://clusters.example.com/minimal.example.com/backups/etcd/main --etcd-image=k8s.gcr.io/etcd:3.4.3 --initialize-rbac=true --manage-etcd=true --master=true --node-name=master.override.invalid --peer-ca=/srv/kubernetes/ca.crt --peer-cert=/srv/kubernetes/etcd-peer.pem --peer-key=/srv/kubernetes/etcd-peer-key.pem --tls-auth=true --tls-ca=/srv/kubernetes/ca.crt --tls-cert=/srv/kubernetes/etcd.pem --tls-key=/srv/kubernetes/etcd-key.pem --v=4 --zone=*/Z1AFAKE1ZON3YO
Restart=always
RestartSec=2s
RestartSec=3s
StartLimitInterval=0

[Install]
Expand Down