diff --git a/samples/generate-yaml.sh b/samples/generate-yaml.sh index 136e4cc281..b486f6e934 100755 --- a/samples/generate-yaml.sh +++ b/samples/generate-yaml.sh @@ -118,8 +118,8 @@ TEMPLATES_PATH=${TEMPLATES_PATH:-$PWD/$SUPPORTED_PROVIDER_OS} HOME_DIR=${PWD%%/samples/*} CONFIG_DIR=$PWD/templates/clouds-secrets/configs USERDATA=$PWD/templates/user-data -MASTER_USER_DATA=$USERDATA/$PROVIDER_OS/templates/master-user-data.sh -WORKER_USER_DATA=$USERDATA/$PROVIDER_OS/templates/worker-user-data.sh +MASTER_USER_DATA=$USERDATA/$PROVIDER_OS/templates/master-user-data.sh.template +WORKER_USER_DATA=$USERDATA/$PROVIDER_OS/templates/worker-user-data.sh.template # Container Linux (simply named CoreOS here) does its configuration a bit different # so it gets some of its own vars here. diff --git a/samples/templates/cluster.yaml b/samples/templates/cluster.yaml index 6c06fa0fe1..fa78ffce97 100644 --- a/samples/templates/cluster.yaml +++ b/samples/templates/cluster.yaml @@ -1,7 +1,7 @@ apiVersion: cluster.x-k8s.io/v1alpha2 kind: Cluster metadata: - name: cluster001 + name: test-cluster namespace: default spec: clusterNetwork: @@ -13,17 +13,21 @@ spec: infrastructureRef: kind: OpenStackCluster apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 - name: cluster001 + name: test-cluster namespace: default --- apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 kind: OpenStackCluster metadata: - name: cluster001 + name: test-cluster namespace: default spec: tags: - a_cluster_wide_tag + cloudName: + cloudsSecret: + name: cloud-config + namespace: capo-system clusterConfiguration: controlPlaneEndpoint: :6443 kubernetesVersion: 1.15.0 diff --git a/samples/templates/machines.yaml b/samples/templates/machines.yaml index d6ec1761e4..cf3b54bb5a 100644 --- a/samples/templates/machines.yaml +++ b/samples/templates/machines.yaml @@ -17,13 +17,14 @@ spec: apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 namespace: default name: test-cluster-kube-master-01 - version: "v1.15.0" + version: "1.15.0" --- apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 kind: OpenStackMachine metadata: name: test-cluster-kube-master-01 spec: + cloudName: flavor: m1.medium image: keyName: cluster-api-provider-openstack @@ -49,11 +50,11 @@ metadata: spec: clusterConfiguration: certificatesDir: /etc/kubernetes/pki - controlPlaneEndpoint: "53.48.112.86:6443" + controlPlaneEndpoint: dns: type: "CoreDNS" imageRepository: "k8s.gcr.io" - kubernetesVersion: v1.14.2 + kubernetesVersion: 1.15.0 networking: dnsDomain: "" podSubnet: "" @@ -78,13 +79,14 @@ spec: apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 namespace: default name: test-cluster-openstack-node-01 - version: "v1.15.0" + version: "1.15.0" --- apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 kind: OpenStackMachine metadata: name: test-cluster-openstack-node-01 spec: + cloudName: flavor: m1.medium image: keyName: cluster-api-provider-openstack diff --git a/samples/templates/user-data/centos/templates/master-user-data.sh b/samples/templates/user-data/centos/templates/master-user-data.sh index 559cc4e7d1..7b478906dd 100644 --- a/samples/templates/user-data/centos/templates/master-user-data.sh +++ b/samples/templates/user-data/centos/templates/master-user-data.sh @@ -66,7 +66,7 @@ echo $OPENSTACK_CLOUD_CACERT_CONFIG | base64 -d > /etc/certs/cacert # Setup certificates -mkdir - /etc/kubernetes/pki /etc/kubernetes/pki/etcd +mkdir /etc/kubernetes/pki /etc/kubernetes/pki/etcd cat > /etc/kubernetes/pki/ca.crt < /etc/apt/sources.list.d/kubernetes.list' -apt-get update -y -apt-get install -y \ - prips - -# Getting local ip from the metadata of the node. -echo "Getting local ip from metadata" -for i in $(seq 60); do - echo "trying to get local-ipv4 $i / 60" - OPENSTACK_IPV4_LOCAL=$(curl --fail -s http://169.254.169.254/latest/meta-data/local-ipv4) - if [[ $? == 0 ]] && [[ -n "$OPENSTACK_IPV4_LOCAL" ]]; then - break - fi - sleep 1 -done - -function install_configure_docker () { - # prevent docker from auto-starting - echo "exit 101" > /usr/sbin/policy-rc.d - chmod +x /usr/sbin/policy-rc.d - trap "rm /usr/sbin/policy-rc.d" RETURN - apt-get install -y docker.io - echo 'DOCKER_OPTS="--iptables=false --ip-masq=false"' > /etc/default/docker - - # Reset iptables config - mkdir -p /etc/systemd/system/docker.service.d - cat > /etc/systemd/system/docker.service.d/10-iptables.conf < /usr/bin/kubeadm.dl -chmod a+rx /usr/bin/kubeadm.dl - -# Our Debian packages have versions like "1.8.0-00" or "1.8.0-01". Do a prefix -# search based on our SemVer to find the right (newest) package version. -function getversion() { - name=$1 - prefix=$2 - version=$(apt-cache madison $name | awk '{ print $3 }' | grep ^$prefix | head -n1) - if [[ -z "$version" ]]; then - echo Can\'t find package $name with prefix $prefix - exit 1 - fi - echo $version -} -KUBELET=$(getversion kubelet ${KUBELET_VERSION}-) -KUBEADM=$(getversion kubeadm ${KUBELET_VERSION}-) -KUBECTL=$(getversion kubectl ${KUBELET_VERSION}-) -apt-get install -y \ - kubelet=${KUBELET} \ - kubeadm=${KUBEADM} \ - kubectl=${KUBECTL} - -mv /usr/bin/kubeadm.dl /usr/bin/kubeadm -chmod a+rx /usr/bin/kubeadm - -echo W0dsb2JhbF0KYXV0aC11cmw9bnVsbAp1c2VybmFtZT0ibnVsbCIKcGFzc3dvcmQ9Im51bGwiCnJlZ2lvbj0ibnVsbCIKdGVuYW50LWlkPSJudWxsIgpkb21haW4tbmFtZT0ibnVsbCIKCg== | base64 -d > /etc/kubernetes/cloud.conf -chmod 600 /etc/kubernetes/cloud.conf -mkdir /etc/certs -echo | base64 -d > /etc/certs/cacert - -systemctl daemon-reload -systemctl restart kubelet.service -systemctl disable ufw -systemctl mask ufw - -# Setup certificates -mkdir - /etc/kubernetes/pki /etc/kubernetes/pki/etcd -cat > /etc/kubernetes/pki/ca.crt < /etc/kubernetes/pki/ca.key < /etc/kubernetes/pki/etcd/ca.crt < /etc/kubernetes/pki/etcd/ca.key < /etc/kubernetes/pki/front-proxy-ca.crt < /etc/kubernetes/pki/front-proxy-ca.key < /etc/kubernetes/pki/sa.pub < /etc/kubernetes/pki/sa.key < /etc/kubernetes/kubeadm_config.yaml <&1 | tee /var/log/startup.log diff --git a/samples/templates/user-data/ubuntu/templates/master-user-data.sh b/samples/templates/user-data/ubuntu/templates/master-user-data.sh.template similarity index 98% rename from samples/templates/user-data/ubuntu/templates/master-user-data.sh rename to samples/templates/user-data/ubuntu/templates/master-user-data.sh.template index e81d7ff012..5be00cd237 100644 --- a/samples/templates/user-data/ubuntu/templates/master-user-data.sh +++ b/samples/templates/user-data/ubuntu/templates/master-user-data.sh.template @@ -90,7 +90,7 @@ systemctl disable ufw systemctl mask ufw # Setup certificates -mkdir - /etc/kubernetes/pki /etc/kubernetes/pki/etcd +mkdir /etc/kubernetes/pki /etc/kubernetes/pki/etcd cat > /etc/kubernetes/pki/ca.crt < /etc/apt/sources.list.d/k8s.list -deb [arch=amd64] https://apt.dockerproject.org/repo ubuntu-xenial main -EOF -apt-get update - -function install_configure_docker () { - # prevent docker from auto-starting - echo "exit 101" > /usr/sbin/policy-rc.d - chmod +x /usr/sbin/policy-rc.d - trap "rm /usr/sbin/policy-rc.d" RETURN - apt-get install -y docker.io - echo 'DOCKER_OPTS="--iptables=false --ip-masq=false"' > /etc/default/docker - - # Reset iptables config - mkdir -p /etc/systemd/system/docker.service.d - cat > /etc/systemd/system/docker.service.d/10-iptables.conf < /etc/apt/sources.list.d/kubernetes.list -deb http://apt.kubernetes.io/ kubernetes-xenial main -EOF -apt-get update - -# Needed for the node and kubeadm preflights -modprobe ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr - -mkdir -p /etc/kubernetes/ -# Our Debian packages have versions like "1.8.0-00" or "1.8.0-01". Do a prefix -# search based on our SemVer to find the right (newest) package version. -function getversion() { - name=$1 - prefix=$2 - version=$(apt-cache madison $name | awk '{ print $3 }' | grep ^$prefix | head -n1) - if [[ -z "$version" ]]; then - echo Can\'t find package $name with prefix $prefix - exit 1 - fi - echo $version -} -KUBELET=$(getversion kubelet ${KUBELET_VERSION}-) -KUBEADM=$(getversion kubeadm ${KUBELET_VERSION}-) -KUBECTL=$(getversion kubectl ${KUBELET_VERSION}-) -apt-get install -y kubelet=${KUBELET} kubeadm=${KUBEADM} kubectl=${KUBECTL} -# kubeadm uses 10th IP as DNS server - -# Write the cloud.conf so that the kubelet can use it. -echo W0dsb2JhbF0KYXV0aC11cmw9bnVsbAp1c2VybmFtZT0ibnVsbCIKcGFzc3dvcmQ9Im51bGwiCnJlZ2lvbj0ibnVsbCIKdGVuYW50LWlkPSJudWxsIgpkb21haW4tbmFtZT0ibnVsbCIKCg== | base64 -d > /etc/kubernetes/cloud.conf -mkdir /etc/certs -echo | base64 -d > /etc/certs/cacert - -# Set up kubeadm config file to pass to kubeadm join. -cat > /etc/kubernetes/kubeadm_config.yaml <&1 | tee /var/log/startup.log