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

Commit

Permalink
Merge pull request #1852 from jorge07/flatcar-0.14.x
Browse files Browse the repository at this point in the history
Flatcar migration for 0.14.x
  • Loading branch information
dominicgunn authored May 18, 2020
2 parents 8769d92 + 7614e68 commit b512f0a
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 56 deletions.
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
}
File renamed without changes.
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

0 comments on commit b512f0a

Please sign in to comment.