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

Add channels entries for image architecture #11046

Merged
merged 1 commit into from
Mar 15, 2021
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
34 changes: 28 additions & 6 deletions channels/alpha
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,81 @@ spec:
# We put the "legacy" version first, for kops versions that don't support versions ( < 1.5.0 )
- name: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2017-07-28
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.4.0 <1.5.0"
- name: kope.io/k8s-1.5-debian-jessie-amd64-hvm-ebs-2018-08-17
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.5.0 <1.6.0"
- name: kope.io/k8s-1.6-debian-jessie-amd64-hvm-ebs-2018-08-17
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.6.0 <1.7.0"
- name: kope.io/k8s-1.7-debian-jessie-amd64-hvm-ebs-2018-08-17
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.7.0 <1.8.0"
- name: kope.io/k8s-1.8-debian-stretch-amd64-hvm-ebs-2018-08-17
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.8.0 <1.9.0"
- name: kope.io/k8s-1.9-debian-stretch-amd64-hvm-ebs-2018-08-17
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.9.0 <1.10.0"
- name: kope.io/k8s-1.10-debian-stretch-amd64-hvm-ebs-2018-08-17
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.10.0 <1.11.0"
# Stretch is the default for 1.11 (for nvme)
- name: kope.io/k8s-1.11-debian-stretch-amd64-hvm-ebs-2021-02-05
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.11.0 <1.12.0"
- name: kope.io/k8s-1.12-debian-stretch-amd64-hvm-ebs-2021-02-05
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.12.0 <1.13.0"
- name: kope.io/k8s-1.13-debian-stretch-amd64-hvm-ebs-2021-02-05
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.13.0 <1.14.0"
- name: kope.io/k8s-1.14-debian-stretch-amd64-hvm-ebs-2021-02-05
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.14.0 <1.15.0"
- name: kope.io/k8s-1.15-debian-stretch-amd64-hvm-ebs-2021-02-05
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.15.0 <1.16.0"
- name: kope.io/k8s-1.16-debian-stretch-amd64-hvm-ebs-2021-02-05
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.16.0 <1.17.0"
- name: kope.io/k8s-1.17-debian-stretch-amd64-hvm-ebs-2021-02-05
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.17.0 <1.18.0"
- name: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20210119.1
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.18.0"
- providerID: gce
- name: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-arm64-server-20210119.1
providerID: aws
architectureID: arm64
kubernetesVersion: ">=1.20.0"
- name: "cos-cloud/cos-stable-65-10323-99-0"
providerID: gce
architectureID: amd64
kubernetesVersion: "<1.16.0-alpha.1"
name: "cos-cloud/cos-stable-65-10323-99-0"
- providerID: gce
- name: "cos-cloud/cos-stable-77-12371-114-0"
providerID: gce
architectureID: amd64
kubernetesVersion: ">=1.16.0-alpha.1"
name: "cos-cloud/cos-stable-77-12371-114-0"
- providerID: gce
- name: "ubuntu-os-cloud/ubuntu-2004-focal-v20210119a"
providerID: gce
architectureID: amd64
kubernetesVersion: ">=1.17.0"
name: "ubuntu-os-cloud/ubuntu-2004-focal-v20210119a"
cluster:
kubernetesVersion: v1.5.8
networking:
Expand Down
48 changes: 35 additions & 13 deletions channels/stable
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,94 @@ spec:
# We put the "legacy" version first, for kops versions that don't support versions ( < 1.5.0 )
- name: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2017-07-28
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.4.0 <1.5.0"
- name: kope.io/k8s-1.5-debian-jessie-amd64-hvm-ebs-2018-08-17
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.5.0 <1.6.0"
- name: kope.io/k8s-1.6-debian-jessie-amd64-hvm-ebs-2018-08-17
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.6.0 <1.7.0"
- name: kope.io/k8s-1.7-debian-jessie-amd64-hvm-ebs-2018-08-17
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.7.0 <1.8.0"
- name: kope.io/k8s-1.8-debian-stretch-amd64-hvm-ebs-2018-08-17
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.8.0 <1.9.0"
- name: kope.io/k8s-1.9-debian-stretch-amd64-hvm-ebs-2018-08-17
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.9.0 <1.10.0"
- name: kope.io/k8s-1.10-debian-stretch-amd64-hvm-ebs-2018-08-17
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.10.0 <1.11.0"
# Stretch is the default for 1.11 (for nvme)
- name: kope.io/k8s-1.11-debian-stretch-amd64-hvm-ebs-2021-02-05
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.11.0 <1.12.0"
- name: kope.io/k8s-1.12-debian-stretch-amd64-hvm-ebs-2021-02-05
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.12.0 <1.13.0"
- name: kope.io/k8s-1.13-debian-stretch-amd64-hvm-ebs-2021-02-05
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.13.0 <1.14.0"
- name: kope.io/k8s-1.14-debian-stretch-amd64-hvm-ebs-2021-02-05
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.14.0 <1.15.0"
- name: kope.io/k8s-1.15-debian-stretch-amd64-hvm-ebs-2021-02-05
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.15.0 <1.16.0"
- name: kope.io/k8s-1.16-debian-stretch-amd64-hvm-ebs-2021-02-05
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.16.0 <1.17.0"
- name: kope.io/k8s-1.17-debian-stretch-amd64-hvm-ebs-2021-02-05
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.17.0 <1.18.0"
- name: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20210119.1
providerID: aws
architectureID: amd64
kubernetesVersion: ">=1.18.0"
- providerID: gce
- name: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-arm64-server-20210119.1
providerID: aws
architectureID: arm64
kubernetesVersion: ">=1.20.0"
- name: "cos-cloud/cos-stable-65-10323-99-0"
providerID: gce
architectureID: amd64
kubernetesVersion: "<1.16.0-alpha.1"
name: "cos-cloud/cos-stable-65-10323-99-0"
- providerID: gce
- name: "cos-cloud/cos-stable-77-12371-114-0"
providerID: gce
architectureID: amd64
kubernetesVersion: ">=1.16.0-alpha.1"
name: "cos-cloud/cos-stable-77-12371-114-0"
- providerID: gce
- name: "ubuntu-os-cloud/ubuntu-2004-focal-v20210119a"
providerID: gce
architectureID: amd64
kubernetesVersion: ">=1.17.0"
name: "ubuntu-os-cloud/ubuntu-2004-focal-v20210119a"
cluster:
kubernetesVersion: v1.5.8
networking:
kubenet: {}
kubernetesVersions:
- range: ">=1.20.0"
recommendedVersion: 1.20.2
recommendedVersion: 1.20.4
requiredVersion: 1.20.0
- range: ">=1.19.0"
recommendedVersion: 1.19.7
recommendedVersion: 1.19.8
requiredVersion: 1.19.0
- range: ">=1.18.0"
recommendedVersion: 1.18.15
recommendedVersion: 1.18.16
requiredVersion: 1.18.0
- range: ">=1.17.0"
recommendedVersion: 1.17.17
Expand Down Expand Up @@ -97,16 +119,16 @@ spec:
kopsVersions:
- range: ">=1.20.0-alpha.1"
#recommendedVersion: "1.19.0-beta.3"
#requiredVersion: 1.19.0
kubernetesVersion: 1.20.2
#requiredVersion: 1.20.0
kubernetesVersion: 1.20.4
- range: ">=1.19.0-beta.3"
#recommendedVersion: "1.19.0-beta.3"
#requiredVersion: 1.19.0
kubernetesVersion: 1.19.7
kubernetesVersion: 1.19.8
- range: ">=1.18.0-alpha.1"
recommendedVersion: "1.18.2"
#requiredVersion: 1.18.0
kubernetesVersion: 1.18.15
kubernetesVersion: 1.18.16
- range: ">=1.17.0-alpha.1"
recommendedVersion: "1.18.2"
#requiredVersion: 1.17.0
Expand Down
49 changes: 26 additions & 23 deletions cmd/kops/upgrade_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ import (

"github.com/blang/semver/v4"
"github.com/spf13/cobra"
"k8s.io/klog/v2"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog/v2"
"k8s.io/kops"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/apis/kops/util"
Expand Down Expand Up @@ -174,28 +173,32 @@ func (c *UpgradeClusterCmd) Run(ctx context.Context, args []string) error {

// Prompt to upgrade image
if proposedKubernetesVersion != nil {
image := channel.FindImage(cloud.ProviderID(), *proposedKubernetesVersion)

if image == nil {
klog.Warningf("No matching images specified in channel; cannot prompt for upgrade")
} else {
for _, ig := range instanceGroups {
if channel.HasUpstreamImagePrefix(ig.Spec.Image) {
if ig.Spec.Image != image.Name {
target := ig
actions = append(actions, &upgradeAction{
Item: "InstanceGroup/" + target.ObjectMeta.Name,
Property: "Image",
Old: target.Spec.Image,
New: image.Name,
apply: func() {
target.Spec.Image = image.Name
},
})
}
} else {
klog.Infof("Custom image (%s) has been provided for Instance Group %q; not updating image", ig.Spec.Image, ig.GetName())
for _, ig := range instanceGroups {
architecture, err := cloudup.MachineArchitecture(cloud, ig.Spec.MachineType)
if err != nil {
klog.Warningf("Error finding architecture for machine type %q: %v", ig.Spec.MachineType, err)
continue
}
image := channel.FindImage(cloud.ProviderID(), *proposedKubernetesVersion, architecture)
if image == nil {
klog.Warningf("No matching images specified in channel; cannot prompt for upgrade")
continue
}
if channel.HasUpstreamImagePrefix(ig.Spec.Image) {
if ig.Spec.Image != image.Name {
target := ig
actions = append(actions, &upgradeAction{
Item: "InstanceGroup/" + target.ObjectMeta.Name,
Property: "Image",
Old: target.Spec.Image,
New: image.Name,
apply: func() {
target.Spec.Image = image.Name
},
})
}
} else {
klog.Infof("Custom image (%s) has been provided for Instance Group %q; not updating image", ig.Spec.Image, ig.GetName())
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/operations/cluster_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ metadata:
kops.k8s.io/cluster: {{ '{{.clusterName}}.{{.dnsZone}}' }}
name: nodes
spec:
image: {{ '{{ ChannelRecommendedImage .cloud .kubernetesVersion }}' }}
image: {{ '{{ ChannelRecommendedImage .cloud .kubernetesVersion .architecture }}' }}
kubernetesVersion: {{ '{{ ChannelRecommendedKubernetesUpgradeVersion .kubernetesVersion }}' }}
machineType: m4.large
maxPrice: "0.5"
Expand Down Expand Up @@ -131,7 +131,7 @@ This function returns the kubernetes version recommended for the running kops ve

This function returns the recommended kubernetes version given that you currently run `<kubernetesVersion>`. Typically this is the latest patch version supported by the given channel.

##### ChannelRecommendedImage <cloudProvider> <kuberneteVersion>
##### ChannelRecommendedImage <cloudProvider> <kuberneteVersion> <architecture>

This function returns the recommended image for the given cloud provider and kubernetes version.

Expand Down
2 changes: 2 additions & 0 deletions docs/releases/1.20-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

* If you are using the Calico network plugin in a cross-subnet setup, you may have to manually remove the AWS Source/Dest Check controller (`k8s-ec2-srcdst`) deployment that was previously deprecated and replaced with the new [awsSrcDstCheck](https://docs.projectcalico.org/reference/resources/felixconfig#spec) feature.

* If you are using self-hosted channels files, you have to add the new `architectureID` field, with one of the `amd64` or `arm64` values.

* If you are running `kops toolbox template` in an airgapped environment, you have to set `--channel` to point to a local channel file.

* If your workload targets control plane nodes, you need to change them to select the `node-role.kubernetes.io/control-plane=""` label. You should also add the `node-role.kubernetes.io/control-plane:NoSchedule` toleration to these workloads. This taint will not be added to control plane nodes before kOps 1.22.
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/kops/BUILD.bazel

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

10 changes: 8 additions & 2 deletions pkg/apis/kops/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog/v2"
"k8s.io/kops/pkg/apis/kops/util"
"k8s.io/kops/util/pkg/architectures"
"k8s.io/kops/util/pkg/vfs"
)

Expand Down Expand Up @@ -78,6 +79,8 @@ type ChannelImageSpec struct {

ProviderID string `json:"providerID,omitempty"`

ArchitectureID string `json:"architectureID,omitempty"`

Name string `json:"name,omitempty"`

KubernetesVersion string `json:"kubernetesVersion,omitempty"`
Expand Down Expand Up @@ -259,13 +262,16 @@ const (
)

// FindImage returns the image for the cloudprovider, or nil if none found
func (c *Channel) FindImage(provider CloudProviderID, kubernetesVersion semver.Version) *ChannelImageSpec {
func (c *Channel) FindImage(provider CloudProviderID, kubernetesVersion semver.Version, architecture architectures.Architecture) *ChannelImageSpec {
var matches []*ChannelImageSpec

for _, image := range c.Spec.Images {
if image.ProviderID != string(provider) {
continue
}
if image.ArchitectureID != "" && image.ArchitectureID != string(architecture) {
continue
}
if image.KubernetesVersion != "" {
versionRange, err := semver.ParseRange(image.KubernetesVersion)
if err != nil {
Expand Down Expand Up @@ -327,7 +333,7 @@ func RecommendedKubernetesVersion(c *Channel, kopsVersionString string) *semver.
// Returns true if the given image name has the stable or alpha channel images prefix. Otherwise false.
func (c *Channel) HasUpstreamImagePrefix(image string) bool {
return strings.HasPrefix(image, "kope.io/k8s-") ||
strings.HasPrefix(image, "099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-") ||
strings.HasPrefix(image, "099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-") ||
strings.HasPrefix(image, "cos-cloud/cos-stable-") ||
strings.HasPrefix(image, "ubuntu-os-cloud/ubuntu-")
}
1 change: 1 addition & 0 deletions pkg/util/templater/BUILD.bazel

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

5 changes: 3 additions & 2 deletions pkg/util/templater/template_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/kops"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/apis/kops/util"
"k8s.io/kops/util/pkg/architectures"
)

// templateFuncsMap returns a map if the template functions for this template
Expand Down Expand Up @@ -63,9 +64,9 @@ func (r *Templater) templateFuncsMap(tm *template.Template) template.FuncMap {

}

funcs["ChannelRecommendedImage"] = func(cloud, k8sVersion string) string {
funcs["ChannelRecommendedImage"] = func(cloud, k8sVersion string, architecture architectures.Architecture) string {
hakman marked this conversation as resolved.
Show resolved Hide resolved
ver, _ := semver.ParseTolerant(k8sVersion)
imageSpec := r.channel.FindImage(kopsapi.CloudProviderID(cloud), ver)
imageSpec := r.channel.FindImage(kopsapi.CloudProviderID(cloud), ver, architecture)
return imageSpec.Name
}

Expand Down
Loading