Skip to content
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ IMAGE_TAG = \
$(shell echo $$(git rev-parse HEAD && if [[ -n $$(git status --porcelain) ]]; then echo '-dirty'; fi)|tr -d ' ')
IMAGE_NAME = $(REGISTRY)/$(REGISTRY_NAMESPACE)/machine-controller:$(IMAGE_TAG)

OS = centos coreos ubuntu sles rhel
OS = centos coreos ubuntu sles rhel flatcar
USERDATA_BIN = $(patsubst %, machine-controller-userdata-%, $(OS))

.PHONY: all
Expand Down
47 changes: 47 additions & 0 deletions cmd/userdata/flatcar/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright 2019 The Machine Controller Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

//
// UserData plugin for flatcar.
//

package main

import (
"flag"

"k8s.io/klog"

"github.com/kubermatic/machine-controller/pkg/userdata/convert"
"github.com/kubermatic/machine-controller/pkg/userdata/flatcar"
userdataplugin "github.com/kubermatic/machine-controller/pkg/userdata/plugin"
)

func main() {
// Parse flags.
var debug bool

flag.BoolVar(&debug, "debug", false, "Switch for enabling the plugin debugging")
flag.Parse()

// Instantiate provider and start plugin.
var provider = &flatcar.Provider{}
var p = userdataplugin.New(convert.NewIgnition(provider), debug)

if err := p.Run(); err != nil {
klog.Fatalf("error running flatcar plugin: %v", err)
}
}
13 changes: 11 additions & 2 deletions pkg/cloudprovider/provider/aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ var (
// The AWS marketplace ID from RedHat
owner: "309956199498",
},
providerconfigtypes.OperatingSystemFlatcar: {
// Be as precise as possible - otherwise we might get a nightly dev build
description: "Flatcar Container Linux stable 2345.3.1 (HVM)",
// The AWS marketplace ID from AWS
owner: "075585003325",
},
}

// cacheLock protects concurrent cache misses against a single key. This usually happens when multiple machines get created simultaneously
Expand Down Expand Up @@ -236,6 +242,8 @@ func getDefaultRootDevicePath(os providerconfigtypes.OperatingSystem) (string, e
return rootDevicePathCoreOSSLES, nil
case providerconfigtypes.OperatingSystemRHEL:
return rootDevicePathUbuntuCentOSRHEL, nil
case providerconfigtypes.OperatingSystemFlatcar:
return rootDevicePathCoreOSSLES, nil
}

return "", fmt.Errorf("no default root path found for %s operating system", os)
Expand Down Expand Up @@ -488,8 +496,9 @@ func (p *provider) Create(machine *v1alpha1.Machine, data *cloudprovidertypes.Pr
}
}

if pc.OperatingSystem != providerconfigtypes.OperatingSystemCoreos {
// Gzip the userdata in case we don't use CoreOS.
if pc.OperatingSystem != providerconfigtypes.OperatingSystemCoreos &&
pc.OperatingSystem != providerconfigtypes.OperatingSystemFlatcar {
// Gzip the userdata in case we don't use CoreOS and Flatcar
userdata, err = convert.GzipString(userdata)
if err != nil {
return nil, fmt.Errorf("failed to gzip the userdata")
Expand Down
12 changes: 7 additions & 5 deletions pkg/providerconfig/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ import (
type OperatingSystem string

const (
OperatingSystemCoreos OperatingSystem = "coreos"
OperatingSystemUbuntu OperatingSystem = "ubuntu"
OperatingSystemCentOS OperatingSystem = "centos"
OperatingSystemSLES OperatingSystem = "sles"
OperatingSystemRHEL OperatingSystem = "rhel"
OperatingSystemCoreos OperatingSystem = "coreos"
OperatingSystemUbuntu OperatingSystem = "ubuntu"
OperatingSystemCentOS OperatingSystem = "centos"
OperatingSystemSLES OperatingSystem = "sles"
OperatingSystemRHEL OperatingSystem = "rhel"
OperatingSystemFlatcar OperatingSystem = "flatcar"
)

type CloudProvider string
Expand Down Expand Up @@ -67,6 +68,7 @@ var (
OperatingSystemCentOS,
OperatingSystemSLES,
OperatingSystemRHEL,
OperatingSystemFlatcar,
}

// AllCloudProviders is a slice containing all supported cloud providers.
Expand Down
54 changes: 54 additions & 0 deletions pkg/userdata/flatcar/flatcar.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Copyright 2019 The Machine Controller Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package flatcar

import (
"encoding/json"

"k8s.io/apimachinery/pkg/runtime"
)

// Config contains specific configuration for Flatcar.
type Config struct {
DisableAutoUpdate bool `json:"disableAutoUpdate"`
DisableLocksmithD bool `json:"disableLocksmithD"`
DisableUpdateEngine bool `json:"disableUpdateEngine"`
}

// LoadConfig retrieves the Flatcar configuration from raw data.
func LoadConfig(r runtime.RawExtension) (*Config, error) {
cfg := Config{}
if len(r.Raw) == 0 {
return &cfg, nil
}
if err := json.Unmarshal(r.Raw, &cfg); err != nil {
return nil, err
}
return &cfg, nil
}

// Spec return the configuration as raw data.
func (cfg *Config) Spec() (*runtime.RawExtension, error) {
ext := &runtime.RawExtension{}
b, err := json.Marshal(cfg)
if err != nil {
return nil, err
}

ext.Raw = b
return ext, nil
}
Loading