Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

[v0.14.5] Flatcar migration for 0.14.x #1852

Merged
merged 2 commits into from
May 18, 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
8 changes: 4 additions & 4 deletions builtin/files/cluster.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ clusterName: {{.ClusterName}}
# The URI of the S3 bucket for the cluster
s3URI: {{.S3URI}}

# CoreOS release channel to use. Currently supported options: alpha, beta, stable
# Flatcar release channel to use. Currently supported options: alpha, beta, stable
# See coreos.com/releases for more information
#releaseChannel: stable

# The AMI ID of CoreOS.
# The AMI ID of Flatcar.
#
# To update this to the latest AMI run the following command with the appropriate region and channel then place the resulting ID here
# REGION=eu-west-1 && CHANNEL=stable && curl -s https://coreos.com/dist/aws/aws-$CHANNEL.json | jq -r ".\"$REGION\".hvm"
# REGION=eu-west-1 CHANNEL=stable curl -s https://$CHANNEL.release.flatcar-linux.net/amd64-usr/current/flatcar_production_ami_all.json | jq -r ".amis[] | select(.name==\"$REGION\") .hvm
amiId: "{{.AmiId}}"

# Container Linux has automatic updates https://coreos.com/os/docs/latest/update-strategies.html. This can be a risk in certain situations and this is why is disabled by default and you can enable it by setting this param to false.
# Flatcar has automatic updates https://docs.flatcar-linux.org/os/update-strategies/#disable-automatic-updates-daemon. This can be a risk in certain situations and this is why is disabled by default and you can enable it by setting this param to false.
disableContainerLinuxAutomaticUpdates: true

# Customizes how kube-aws deals with CloudFormation
Expand Down
2 changes: 1 addition & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/kubernetes-incubator/kube-aws/builtin"
"github.com/kubernetes-incubator/kube-aws/core/root/config"
"github.com/kubernetes-incubator/kube-aws/coreos/amiregistry"
"github.com/kubernetes-incubator/kube-aws/filegen"
"github.com/kubernetes-incubator/kube-aws/flatcar/amiregistry"
"github.com/kubernetes-incubator/kube-aws/logger"
"github.com/spf13/cobra"
)
Expand Down
49 changes: 0 additions & 49 deletions coreos/amiregistry/amiregistry.go

This file was deleted.

50 changes: 50 additions & 0 deletions flatcar/amiregistry/amiregistry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package amiregistry

import (
"encoding/json"
"fmt"
)

func GetAMI(region, channel string) (string, error) {

amis, err := GetAMIData(channel)

if err != nil {
return "", fmt.Errorf("uanble to fetch AMI for channel \"%s\": %v", channel, err)
}

for _, v := range amis {
if v["name"] != region {
continue
}
if hvm, ok := v["hvm"]; ok {
return hvm, nil
} else {
break
}
}

return "", fmt.Errorf("could not find \"hvm\" image for region \"%s\" in flatcar channel \"%s\"", region, channel)
}

func GetAMIData(channel string) ([]map[string]string, error) {
url := fmt.Sprintf("https://%s.release.flatcar-linux.net/amd64-usr/current/flatcar_production_ami_all.json", channel)
r, err := newHttp().Get(url)
if err != nil {
return nil, fmt.Errorf("failed to get AMI data from url \"%s\": %v", channel, err)
}

if r.StatusCode != 200 {
return nil, fmt.Errorf("failed to get AMI data from url \"%s\": invalid status code: %d", url, r.StatusCode)
}

output := map[string][]map[string]string{}

err = json.NewDecoder(r.Body).Decode(&output)
if err != nil {
return nil, fmt.Errorf("failed to parse AMI data from url \"%s\": %v", url, err)
}
r.Body.Close()

return output["amis"], nil
}
2 changes: 1 addition & 1 deletion pkg/model/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/kubernetes-incubator/kube-aws/coreos/amiregistry"
"github.com/kubernetes-incubator/kube-aws/flatcar/amiregistry"
"github.com/kubernetes-incubator/kube-aws/pkg/api"
"github.com/pkg/errors"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/node_pool_compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package model
import (
"fmt"

"github.com/kubernetes-incubator/kube-aws/coreos/amiregistry"
"github.com/kubernetes-incubator/kube-aws/flatcar/amiregistry"
"github.com/kubernetes-incubator/kube-aws/logger"
"github.com/kubernetes-incubator/kube-aws/pkg/api"
"github.com/pkg/errors"
Expand Down