Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add MachineDeployment example #1060

Merged
merged 1 commit into from
Aug 22, 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
3 changes: 3 additions & 0 deletions examples/cluster/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ kind: Cluster
metadata:
name: ${CLUSTER_NAME}
spec:
clusterNetwork:
pods:
cidrBlocks: ["192.168.0.0/16"]
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
kind: AWSCluster
Expand Down
9 changes: 8 additions & 1 deletion examples/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ command -v "${ENVSUBST}" >/dev/null 2>&1 || echo -v "Cannot find ${ENVSUBST} in
CLUSTERAWSADM=${CLUSTERAWSADM:-clusterawsadm}
command -v "${CLUSTERAWSADM}" >/dev/null 2>&1 || echo -v "Cannot find ${CLUSTERAWSADM} in path, build it using 'make binaries' in this repository."

# Cluster name.
# Cluster.
export CLUSTER_NAME="${CLUSTER_NAME:-test1}"
export KUBERNETES_VERSION="${KUBERNETES_VERSION:-v1.14.4}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably update the other existing templates for the k8s version env variable as well.


# Machine settings.
export CONTROL_PLANE_MACHINE_TYPE="${CONTROL_PLANE_MACHINE_TYPE:-t2.medium}"
Expand All @@ -43,6 +44,8 @@ COMPONENTS_AWS_GENERATED_FILE=${SOURCE_DIR}/provider-components/provider-compone
PROVIDER_COMPONENTS_GENERATED_FILE=${OUTPUT_DIR}/provider-components.yaml
CLUSTER_GENERATED_FILE=${OUTPUT_DIR}/cluster.yaml
CONTROLPLANE_GENERATED_FILE=${OUTPUT_DIR}/controlplane.yaml
MACHINEDEPLOYMENT_GENERATED_FILE=${OUTPUT_DIR}/machinedeployment.yaml
MACHINES_GENERATED_FILE=${OUTPUT_DIR}/machines.yaml

# Overwrite flag.
OVERWRITE=0
Expand Down Expand Up @@ -93,6 +96,10 @@ echo "Generated ${CLUSTER_GENERATED_FILE}"
kustomize build "${SOURCE_DIR}/controlplane" | envsubst > "${CONTROLPLANE_GENERATED_FILE}"
echo "Generated ${CONTROLPLANE_GENERATED_FILE}"

# Generate machinedeployment resources.
kustomize build "${SOURCE_DIR}/machinedeployment" | envsubst >> "${MACHINEDEPLOYMENT_GENERATED_FILE}"
echo "Generated ${MACHINEDEPLOYMENT_GENERATED_FILE}"

# Generate Cluster API provider components file.
kustomize build "github.com/kubernetes-sigs/cluster-api//config/default/?ref=master" > "${COMPONENTS_CLUSTER_API_GENERATED_FILE}"
echo "Generated ${COMPONENTS_CLUSTER_API_GENERATED_FILE}"
Expand Down
7 changes: 7 additions & 0 deletions examples/machinedeployment/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: default
resources:
- machinedeployment.yaml
configurations:
- kustomizeconfig.yaml
11 changes: 11 additions & 0 deletions examples/machinedeployment/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace:
- kind: MachineDeployment
group: cluster.x-k8s.io
version: v1alpha2
path: spec/template/spec/infrastructureRef/namespace
create: true
- kind: MachineDeployment
group: cluster.x-k8s.io
version: v1alpha2
path: spec/template/spec/bootstrap/configRef/namespace
create: true
46 changes: 46 additions & 0 deletions examples/machinedeployment/machinedeployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: cluster.x-k8s.io/v1alpha2
kind: MachineDeployment
metadata:
name: ${CLUSTER_NAME}-md-0
labels:
cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME}
spec:
replicas: 1
selector:
matchLabels:
cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME}
template:
metadata:
labels:
cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME}
spec:
version: ${KUBERNETES_VERSION}
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
kind: KubeadmConfigTemplate
name: ${CLUSTER_NAME}-md-0
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
kind: AWSMachineTemplate
name: ${CLUSTER_NAME}-md-0
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
kind: AWSMachineTemplate
metadata:
name: ${CLUSTER_NAME}-md-0
spec:
instanceType: ${CONTROL_PLANE_MACHINE_TYPE}
iamInstanceProfile: "control-plane.cluster-api-provider-aws.sigs.k8s.io"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be nodes.cluster-api-provider-aws.sigs.k8s.io instead of control-plane

keyName: "${SSH_KEY_NAME}"
---
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
kind: KubeadmConfigTemplate
metadata:
name: ${CLUSTER_NAME}-md-0
spec:
joinConfiguration:
nodeRegistration:
name: '{{ ds.meta_data.hostname }}'
kubeletExtraArgs:
cloud-provider: aws