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

Capi bump #92

Merged
merged 3 commits into from
Jul 17, 2019
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 cmd/capd-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (

func main() {
// Must set up klog for the cluster api loggers
klog.InitFlags(flag.CommandLine)
klog.InitFlags(nil)
flag.Parse()

log := klogr.New()
Expand Down
2 changes: 1 addition & 1 deletion cmd/capdctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (mo *machineDeploymentOptions) initFlags(fs *flag.FlagSet) {
func main() {
setup := flag.NewFlagSet("setup", flag.ExitOnError)
managementClusterName := setup.String("cluster-name", "management", "The name of the management cluster")
version := setup.String("capi-version", "v0.1.6", "The CRD versions to pull from CAPI. Does not support < v0.1.6.")
version := setup.String("capi-version", "v0.1.7", "The CRD versions to pull from CAPI. Does not support < v0.1.7.")
capdImage := setup.String("capd-image", "gcr.io/kubernetes1-226021/capd-manager:latest", "The capd manager image to run")
capiImage := setup.String("capi-image", "", "This is normally left blank and filled in automatically. But this will override the generated image name.")

Expand Down
4 changes: 4 additions & 0 deletions examples/simple-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ metadata:
set: "controlplane"
spec:
providerSpec: {}
versions:
controlPlane: "v1.14.2"
---
apiVersion: "cluster.k8s.io/v1alpha1"
kind: Machine
Expand All @@ -31,3 +33,5 @@ metadata:
name: "my-cluster-worker"
spec:
providerSpec: {}
versions:
kubelet: "v1.14.2"
60 changes: 36 additions & 24 deletions objects/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,40 @@ limitations under the License.
package objects

import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
capi "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1alpha1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
)

const controlPlaneSet = "controlplane"

// GetMachineDeployment returns a worker node machine deployment object
func GetMachineDeployment(name, namespace, clusterName, kubeletVersion string, replicas int32) capi.MachineDeployment {
func GetMachineDeployment(name, namespace, clusterName, kubeletVersion string, replicas int32) clusterv1alpha1.MachineDeployment {
labels := map[string]string{
"cluster.k8s.io/cluster-name": clusterName,
"set": "node",
}
return capi.MachineDeployment{
ObjectMeta: meta.ObjectMeta{
return clusterv1alpha1.MachineDeployment{
TypeMeta: metav1.TypeMeta{
Kind: "MachineDeployment",
APIVersion: "cluster.k8s.io/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Labels: labels,
},
Spec: capi.MachineDeploymentSpec{
Spec: clusterv1alpha1.MachineDeploymentSpec{
Replicas: &replicas,
Selector: meta.LabelSelector{
Selector: metav1.LabelSelector{
MatchLabels: labels,
},
Template: capi.MachineTemplateSpec{
ObjectMeta: meta.ObjectMeta{
Template: clusterv1alpha1.MachineTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
},
Spec: capi.MachineSpec{
ProviderSpec: capi.ProviderSpec{},
Versions: capi.MachineVersionInfo{
Spec: clusterv1alpha1.MachineSpec{
ProviderSpec: clusterv1alpha1.ProviderSpec{},
Versions: clusterv1alpha1.MachineVersionInfo{
Kubelet: kubeletVersion,
},
},
Expand All @@ -56,18 +60,22 @@ func GetMachineDeployment(name, namespace, clusterName, kubeletVersion string, r
}

// GetCluster returns a cluster object with the given name and namespace
func GetCluster(clusterName, namespace string) capi.Cluster {
return capi.Cluster{
ObjectMeta: meta.ObjectMeta{
func GetCluster(clusterName, namespace string) clusterv1alpha1.Cluster {
return clusterv1alpha1.Cluster{
TypeMeta: metav1.TypeMeta{
Kind: "Cluster",
APIVersion: "cluster.k8s.io/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: clusterName,
Namespace: namespace,
},
Spec: capi.ClusterSpec{
ClusterNetwork: capi.ClusterNetworkingConfig{
Services: capi.NetworkRanges{
Spec: clusterv1alpha1.ClusterSpec{
ClusterNetwork: clusterv1alpha1.ClusterNetworkingConfig{
Services: clusterv1alpha1.NetworkRanges{
CIDRBlocks: []string{"10.96.0.0/12"},
},
Pods: capi.NetworkRanges{
Pods: clusterv1alpha1.NetworkRanges{
CIDRBlocks: []string{"192.168.0.0/16"},
},
ServiceDomain: "cluster.local",
Expand All @@ -77,18 +85,22 @@ func GetCluster(clusterName, namespace string) capi.Cluster {
}

// GetMachine returns a machine with the given parameters
func GetMachine(name, namespace, clusterName, set, version string) capi.Machine {
machine := capi.Machine{
ObjectMeta: meta.ObjectMeta{
func GetMachine(name, namespace, clusterName, set, version string) clusterv1alpha1.Machine {
machine := clusterv1alpha1.Machine{
TypeMeta: metav1.TypeMeta{
Kind: "Machine",
APIVersion: "cluster.k8s.io/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Labels: map[string]string{
"cluster.k8s.io/cluster-name": clusterName,
"set": set,
},
},
Spec: capi.MachineSpec{
ProviderSpec: capi.ProviderSpec{},
Spec: clusterv1alpha1.MachineSpec{
ProviderSpec: clusterv1alpha1.ProviderSpec{},
},
}
if set == controlPlaneSet {
Expand Down
6 changes: 2 additions & 4 deletions objects/control_plane.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ func GetStatefulSet(image string) apps.StatefulSet {
{
Name: "capd-manager",
Image: image,
Command: []string{
"capd-manager",
"-v=3",
"-logtostderr=true",
Args: []string{
"-v", "3",
},
VolumeMounts: []core.VolumeMount{
{
Expand Down