Skip to content

Commit

Permalink
Merge pull request #8196 from justinsb/dont_preload_unused_images
Browse files Browse the repository at this point in the history
For dev, don't preload docker images on nodes
  • Loading branch information
k8s-ci-robot committed Jan 5, 2020
2 parents 7826748 + e4ed13e commit e4da659
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 80 deletions.
9 changes: 9 additions & 0 deletions nodeup/pkg/model/protokube.go
Expand Up @@ -55,6 +55,15 @@ func (t *ProtokubeBuilder) Build(c *fi.ModelBuilderContext) error {
return nil
}

if protokubeImage := t.NodeupConfig.ProtokubeImage; protokubeImage != nil {
c.AddTask(&nodetasks.LoadImageTask{
Name: "protokube",
Sources: protokubeImage.Sources,
Hash: protokubeImage.Hash,
Runtime: t.Cluster.Spec.ContainerRuntime,
})
}

if t.IsMaster {
kubeconfig, err := t.BuildPKIKubeconfig("kops")
if err != nil {
Expand Down
Expand Up @@ -481,13 +481,6 @@ Resources.AWSAutoScalingLaunchConfigurationnodesadditionalcidrexamplecom.Propert
- _aws
channels:
- memfs://clusters.example.com/additionalcidr.example.com/addons/bootstrap-channel.yaml
protokubeImage:
hash: 42a9c4324fe26d63ce11f3dd7836371bc93fa06ca8f479807728f3746e27061b
name: protokube:1.15.0
sources:
- https://artifacts.k8s.io/binaries/kops/1.15.0/images/protokube.tar.gz
- https://github.com/kubernetes/kops/releases/download/1.15.0/images-protokube.tar.gz
- https://kubeupv2.s3.amazonaws.com/kops/1.15.0/images/protokube.tar.gz
__EOF_KUBE_ENV
Expand Down
Expand Up @@ -510,13 +510,6 @@ Resources.AWSAutoScalingLaunchConfigurationnodesadditionaluserdataexamplecom.Pro
- _aws
channels:
- memfs://clusters.example.com/additionaluserdata.example.com/addons/bootstrap-channel.yaml
protokubeImage:
hash: 42a9c4324fe26d63ce11f3dd7836371bc93fa06ca8f479807728f3746e27061b
name: protokube:1.15.0
sources:
- https://artifacts.k8s.io/binaries/kops/1.15.0/images/protokube.tar.gz
- https://github.com/kubernetes/kops/releases/download/1.15.0/images-protokube.tar.gz
- https://kubeupv2.s3.amazonaws.com/kops/1.15.0/images/protokube.tar.gz
__EOF_KUBE_ENV
Expand Down
Expand Up @@ -483,13 +483,6 @@ Resources.AWSAutoScalingLaunchConfigurationnodescomplexexamplecom.Properties.Use
- _aws
channels:
- memfs://clusters.example.com/complex.example.com/addons/bootstrap-channel.yaml
protokubeImage:
hash: 42a9c4324fe26d63ce11f3dd7836371bc93fa06ca8f479807728f3746e27061b
name: protokube:1.15.0
sources:
- https://artifacts.k8s.io/binaries/kops/1.15.0/images/protokube.tar.gz
- https://github.com/kubernetes/kops/releases/download/1.15.0/images-protokube.tar.gz
- https://kubeupv2.s3.amazonaws.com/kops/1.15.0/images/protokube.tar.gz
__EOF_KUBE_ENV
Expand Down
Expand Up @@ -469,13 +469,6 @@ Resources.AWSAutoScalingLaunchConfigurationnodescontainerdexamplecom.Properties.
- _aws
channels:
- memfs://clusters.example.com/containerd.example.com/addons/bootstrap-channel.yaml
protokubeImage:
hash: 42a9c4324fe26d63ce11f3dd7836371bc93fa06ca8f479807728f3746e27061b
name: protokube:1.15.0
sources:
- https://artifacts.k8s.io/binaries/kops/1.15.0/images/protokube.tar.gz
- https://github.com/kubernetes/kops/releases/download/1.15.0/images-protokube.tar.gz
- https://kubeupv2.s3.amazonaws.com/kops/1.15.0/images/protokube.tar.gz
__EOF_KUBE_ENV
Expand Down
Expand Up @@ -481,13 +481,6 @@ Resources.AWSAutoScalingLaunchConfigurationnodesminimalexamplecom.Properties.Use
- _aws
channels:
- memfs://clusters.example.com/minimal.example.com/addons/bootstrap-channel.yaml
protokubeImage:
hash: 42a9c4324fe26d63ce11f3dd7836371bc93fa06ca8f479807728f3746e27061b
name: protokube:1.15.0
sources:
- https://artifacts.k8s.io/binaries/kops/1.15.0/images/protokube.tar.gz
- https://github.com/kubernetes/kops/releases/download/1.15.0/images-protokube.tar.gz
- https://kubeupv2.s3.amazonaws.com/kops/1.15.0/images/protokube.tar.gz
__EOF_KUBE_ENV
Expand Down
Expand Up @@ -481,13 +481,6 @@ Resources.AWSAutoScalingLaunchConfigurationnodesexternallbexamplecom.Properties.
- _aws
channels:
- memfs://clusters.example.com/externallb.example.com/addons/bootstrap-channel.yaml
protokubeImage:
hash: 42a9c4324fe26d63ce11f3dd7836371bc93fa06ca8f479807728f3746e27061b
name: protokube:1.15.0
sources:
- https://artifacts.k8s.io/binaries/kops/1.15.0/images/protokube.tar.gz
- https://github.com/kubernetes/kops/releases/download/1.15.0/images-protokube.tar.gz
- https://kubeupv2.s3.amazonaws.com/kops/1.15.0/images/protokube.tar.gz
__EOF_KUBE_ENV
Expand Down
Expand Up @@ -481,13 +481,6 @@ Resources.AWSAutoScalingLaunchConfigurationnodesminimalexamplecom.Properties.Use
- _aws
channels:
- memfs://clusters.example.com/minimal.example.com/addons/bootstrap-channel.yaml
protokubeImage:
hash: 42a9c4324fe26d63ce11f3dd7836371bc93fa06ca8f479807728f3746e27061b
name: protokube:1.15.0
sources:
- https://artifacts.k8s.io/binaries/kops/1.15.0/images/protokube.tar.gz
- https://github.com/kubernetes/kops/releases/download/1.15.0/images-protokube.tar.gz
- https://kubeupv2.s3.amazonaws.com/kops/1.15.0/images/protokube.tar.gz
__EOF_KUBE_ENV
Expand Down
Expand Up @@ -1068,13 +1068,6 @@ Resources.AWSEC2LaunchTemplatenodesmixedinstancesexamplecom.Properties.LaunchTem
- _aws
channels:
- memfs://clusters.example.com/mixedinstances.example.com/addons/bootstrap-channel.yaml
protokubeImage:
hash: 42a9c4324fe26d63ce11f3dd7836371bc93fa06ca8f479807728f3746e27061b
name: protokube:1.15.0
sources:
- https://artifacts.k8s.io/binaries/kops/1.15.0/images/protokube.tar.gz
- https://github.com/kubernetes/kops/releases/download/1.15.0/images-protokube.tar.gz
- https://kubeupv2.s3.amazonaws.com/kops/1.15.0/images/protokube.tar.gz
__EOF_KUBE_ENV
Expand Down
Expand Up @@ -1068,13 +1068,6 @@ Resources.AWSEC2LaunchTemplatenodesmixedinstancesexamplecom.Properties.LaunchTem
- _aws
channels:
- memfs://clusters.example.com/mixedinstances.example.com/addons/bootstrap-channel.yaml
protokubeImage:
hash: 42a9c4324fe26d63ce11f3dd7836371bc93fa06ca8f479807728f3746e27061b
name: protokube:1.15.0
sources:
- https://artifacts.k8s.io/binaries/kops/1.15.0/images/protokube.tar.gz
- https://github.com/kubernetes/kops/releases/download/1.15.0/images-protokube.tar.gz
- https://kubeupv2.s3.amazonaws.com/kops/1.15.0/images/protokube.tar.gz
__EOF_KUBE_ENV
Expand Down
Expand Up @@ -478,13 +478,6 @@ Resources.AWSAutoScalingLaunchConfigurationnodesprivatecalicoexamplecom.Properti
- _aws
channels:
- memfs://clusters.example.com/privatecalico.example.com/addons/bootstrap-channel.yaml
protokubeImage:
hash: 42a9c4324fe26d63ce11f3dd7836371bc93fa06ca8f479807728f3746e27061b
name: protokube:1.15.0
sources:
- https://artifacts.k8s.io/binaries/kops/1.15.0/images/protokube.tar.gz
- https://github.com/kubernetes/kops/releases/download/1.15.0/images-protokube.tar.gz
- https://kubeupv2.s3.amazonaws.com/kops/1.15.0/images/protokube.tar.gz
__EOF_KUBE_ENV
Expand Down
9 changes: 6 additions & 3 deletions upup/pkg/fi/cloudup/apply_cluster.go
Expand Up @@ -1298,12 +1298,15 @@ func (c *ApplyClusterCmd) BuildNodeUpConfig(assetBuilder *assets.AssetBuilder, i
config.ConfigBase = fi.String(configBase.Path())
config.InstanceGroupName = ig.ObjectMeta.Name

useGossip := dns.IsGossipHostname(cluster.Spec.MasterInternalName)
isMaster := role == kops.InstanceGroupRoleMaster

var images []*nodeup.Image

if components.IsBaseURL(cluster.Spec.KubernetesVersion) {
// When using a custom version, we want to preload the images over http
components := []string{"kube-proxy"}
if role == kops.InstanceGroupRoleMaster {
if isMaster {
components = append(components, "kube-apiserver", "kube-controller-manager", "kube-scheduler")
}

Expand All @@ -1330,7 +1333,7 @@ func (c *ApplyClusterCmd) BuildNodeUpConfig(assetBuilder *assets.AssetBuilder, i

// `docker load` our images when using a KOPS_BASE_URL, so we
// don't need to push/pull from a registry
if os.Getenv("KOPS_BASE_URL") != "" {
if os.Getenv("KOPS_BASE_URL") != "" && isMaster {
for _, name := range []string{"kops-controller", "dns-controller"} {
baseURL, err := url.Parse(os.Getenv("KOPS_BASE_URL"))
if err != nil {
Expand All @@ -1352,7 +1355,7 @@ func (c *ApplyClusterCmd) BuildNodeUpConfig(assetBuilder *assets.AssetBuilder, i
}
}

{
if isMaster || useGossip {
u, hash, err := ProtokubeImageSource(assetBuilder)
if err != nil {
return nil, err
Expand Down
8 changes: 1 addition & 7 deletions upup/pkg/fi/nodeup/command.go
Expand Up @@ -301,13 +301,7 @@ func (c *NodeUpCommand) Run(out io.Writer) error {
Runtime: c.cluster.Spec.ContainerRuntime,
}
}
if c.config.ProtokubeImage != nil {
taskMap["LoadImage.protokube"] = &nodetasks.LoadImageTask{
Sources: c.config.ProtokubeImage.Sources,
Hash: c.config.ProtokubeImage.Hash,
Runtime: c.cluster.Spec.ContainerRuntime,
}
}
// Protokube load image task is in ProtokubeBuilder

var cloud fi.Cloud
var keyStore fi.Keystore
Expand Down
14 changes: 14 additions & 0 deletions upup/pkg/fi/nodeup/nodetasks/load_image.go
Expand Up @@ -40,6 +40,7 @@ const (

// LoadImageTask is responsible for downloading a docker image
type LoadImageTask struct {
Name string
Sources []string
Hash string
Runtime string
Expand All @@ -64,6 +65,19 @@ func (t *LoadImageTask) GetDependencies(tasks map[string]fi.Task) []fi.Task {
return deps
}

var _ fi.HasName = &LoadImageTask{}

func (t *LoadImageTask) GetName() *string {
if t.Name == "" {
return nil
}
return &t.Name
}

func (t *LoadImageTask) SetName(name string) {
klog.Fatalf("SetName not supported for LoadImageTask")
}

func (t *LoadImageTask) String() string {
return fmt.Sprintf("LoadImageTask: %v", t.Sources)
}
Expand Down

0 comments on commit e4da659

Please sign in to comment.