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

Commit b512f0a

Browse files
authored
Merge pull request #1852 from jorge07/flatcar-0.14.x
Flatcar migration for 0.14.x
2 parents 8769d92 + 7614e68 commit b512f0a

File tree

8 files changed

+57
-56
lines changed

8 files changed

+57
-56
lines changed

builtin/files/cluster.yaml.tmpl

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ clusterName: {{.ClusterName}}
66
# The URI of the S3 bucket for the cluster
77
s3URI: {{.S3URI}}
88

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

13-
# The AMI ID of CoreOS.
13+
# The AMI ID of Flatcar.
1414
#
1515
# To update this to the latest AMI run the following command with the appropriate region and channel then place the resulting ID here
16-
# REGION=eu-west-1 && CHANNEL=stable && curl -s https://coreos.com/dist/aws/aws-$CHANNEL.json | jq -r ".\"$REGION\".hvm"
16+
# 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
1717
amiId: "{{.AmiId}}"
1818

19-
# 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.
19+
# 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.
2020
disableContainerLinuxAutomaticUpdates: true
2121

2222
# Customizes how kube-aws deals with CloudFormation

cmd/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66

77
"github.com/kubernetes-incubator/kube-aws/builtin"
88
"github.com/kubernetes-incubator/kube-aws/core/root/config"
9-
"github.com/kubernetes-incubator/kube-aws/coreos/amiregistry"
109
"github.com/kubernetes-incubator/kube-aws/filegen"
10+
"github.com/kubernetes-incubator/kube-aws/flatcar/amiregistry"
1111
"github.com/kubernetes-incubator/kube-aws/logger"
1212
"github.com/spf13/cobra"
1313
)

coreos/amiregistry/amiregistry.go

-49
This file was deleted.

flatcar/amiregistry/amiregistry.go

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package amiregistry
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
)
7+
8+
func GetAMI(region, channel string) (string, error) {
9+
10+
amis, err := GetAMIData(channel)
11+
12+
if err != nil {
13+
return "", fmt.Errorf("uanble to fetch AMI for channel \"%s\": %v", channel, err)
14+
}
15+
16+
for _, v := range amis {
17+
if v["name"] != region {
18+
continue
19+
}
20+
if hvm, ok := v["hvm"]; ok {
21+
return hvm, nil
22+
} else {
23+
break
24+
}
25+
}
26+
27+
return "", fmt.Errorf("could not find \"hvm\" image for region \"%s\" in flatcar channel \"%s\"", region, channel)
28+
}
29+
30+
func GetAMIData(channel string) ([]map[string]string, error) {
31+
url := fmt.Sprintf("https://%s.release.flatcar-linux.net/amd64-usr/current/flatcar_production_ami_all.json", channel)
32+
r, err := newHttp().Get(url)
33+
if err != nil {
34+
return nil, fmt.Errorf("failed to get AMI data from url \"%s\": %v", channel, err)
35+
}
36+
37+
if r.StatusCode != 200 {
38+
return nil, fmt.Errorf("failed to get AMI data from url \"%s\": invalid status code: %d", url, r.StatusCode)
39+
}
40+
41+
output := map[string][]map[string]string{}
42+
43+
err = json.NewDecoder(r.Body).Decode(&output)
44+
if err != nil {
45+
return nil, fmt.Errorf("failed to parse AMI data from url \"%s\": %v", url, err)
46+
}
47+
r.Body.Close()
48+
49+
return output["amis"], nil
50+
}

pkg/model/compiler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"strings"
66

7-
"github.com/kubernetes-incubator/kube-aws/coreos/amiregistry"
7+
"github.com/kubernetes-incubator/kube-aws/flatcar/amiregistry"
88
"github.com/kubernetes-incubator/kube-aws/pkg/api"
99
"github.com/pkg/errors"
1010
)

pkg/model/node_pool_compile.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package model
33
import (
44
"fmt"
55

6-
"github.com/kubernetes-incubator/kube-aws/coreos/amiregistry"
6+
"github.com/kubernetes-incubator/kube-aws/flatcar/amiregistry"
77
"github.com/kubernetes-incubator/kube-aws/logger"
88
"github.com/kubernetes-incubator/kube-aws/pkg/api"
99
"github.com/pkg/errors"

0 commit comments

Comments
 (0)