You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by om...@apache.org on 2019/10/10 12:47:35 UTC

[incubator-dlab] branch DLAB-1158 updated: fixed issue with cloud provider configuration

This is an automated email from the ASF dual-hosted git repository.

omartushevskyi pushed a commit to branch DLAB-1158
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git


The following commit(s) were added to refs/heads/DLAB-1158 by this push:
     new bef4c10  fixed issue with cloud provider configuration
bef4c10 is described below

commit bef4c10588d410a1febe8a855f0c7b2949973931
Author: Oleh Martushevskyi <Ol...@epam.com>
AuthorDate: Thu Oct 10 15:47:25 2019 +0300

    fixed issue with cloud provider configuration
---
 .../aws/ssn-k8s/main/auto_scaling_groups.tf        |  1 +
 .../aws/ssn-k8s/main/files/masters-user-data.sh    | 22 +++++++++++++++++++++-
 .../aws/ssn-k8s/main/files/workers-user-data.sh    | 18 ++++++++++++++----
 3 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/infrastructure-provisioning/terraform/aws/ssn-k8s/main/auto_scaling_groups.tf b/infrastructure-provisioning/terraform/aws/ssn-k8s/main/auto_scaling_groups.tf
index 6ed8599..103871a 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-k8s/main/auto_scaling_groups.tf
+++ b/infrastructure-provisioning/terraform/aws/ssn-k8s/main/auto_scaling_groups.tf
@@ -61,6 +61,7 @@ data "template_file" "ssn_k8s_workers_user_data" {
     k8s-bucket-name    = aws_s3_bucket.ssn_k8s_bucket.id
     k8s_os_user        = var.os_user
     kubernetes_version = var.kubernetes_version
+    k8s-nlb-dns-name   = aws_lb.ssn_k8s_nlb.dns_name
   }
 }
 
diff --git a/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/masters-user-data.sh b/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/masters-user-data.sh
index 5b0b310..1c35fe8 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/masters-user-data.sh
+++ b/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/masters-user-data.sh
@@ -170,11 +170,31 @@ do
         break
     fi
 done
+cat <<EOF > /tmp/node.yaml
+---
+apiVersion: kubeadm.k8s.io/v1beta1
+kind: JoinConfiguration
+discovery:
+  bootstrapToken:
+    token: TOKEN
+    apiServerEndpoint: "${k8s-nlb-dns-name}:6443"
+    caCertHashes:
+      - "HASHES"
+nodeRegistration:
+  name: NODE_NAME
+  kubeletExtraArgs:
+    cloud-provider: aws
+EOF
 aws s3 cp s3://${k8s-bucket-name}/k8s/masters/join_command /tmp/join_command
 aws s3 cp s3://${k8s-bucket-name}/k8s/masters/cert_key /tmp/cert_key
 join_command=$(cat /tmp/join_command)
 cert_key=$(cat /tmp/cert_key)
-sudo $join_command --control-plane --certificate-key "$cert_key" --node-name $full_hostname
+token=$(cat /tmp/join_command | sed 's/--\+/\n/g' | grep "token ")
+hashes=$(cat /tmp/join_command | sed 's/--\+/\n/g' | grep "discovery-token-ca-cert-hash" | awk '{print $2}')
+sed -i "s/NODE_NAME/$full_hostname/g" /tmp/node.yaml
+sed -i "s/TOKEN/$token/g" /tmp/node.yaml
+sed -i "s/HASHES/$hashes/g" /tmp/node.yaml
+sudo kubeadm join --config /tmp/node.yaml --control-plane --certificate-key "$cert_key"
 sudo mkdir -p /home/${k8s_os_user}/.kube
 sudo cp -i /etc/kubernetes/admin.conf /home/${k8s_os_user}/.kube/config
 sudo chown -R ${k8s_os_user}:${k8s_os_user} /home/${k8s_os_user}/.kube
diff --git a/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/workers-user-data.sh b/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/workers-user-data.sh
index c665846..44b0435 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/workers-user-data.sh
+++ b/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/workers-user-data.sh
@@ -68,12 +68,22 @@ cat <<EOF > /tmp/node.yaml
 ---
 apiVersion: kubeadm.k8s.io/v1beta1
 kind: JoinConfiguration
+discovery:
+  bootstrapToken:
+    token: TOKEN
+    apiServerEndpoint: "${k8s-nlb-dns-name}:6443"
+    caCertHashes:
+      - "HASHES"
 nodeRegistration:
+  name: NODE_NAME
   kubeletExtraArgs:
     cloud-provider: aws
 EOF
-
-full_hostname=$(curl http://169.254.169.254/latest/meta-data/hostname)
 aws s3 cp s3://${k8s-bucket-name}/k8s/masters/join_command /tmp/join_command
-join_command=$(cat /tmp/join_command)
-sudo $join_command --node-name $full_hostname --config /tmp/node.yaml
+token=$(cat /tmp/join_command | sed 's/--\+/\n/g' | grep "token ")
+hashes=$(cat /tmp/join_command | sed 's/--\+/\n/g' | grep "discovery-token-ca-cert-hash" | awk '{print $2}')
+full_hostname=$(curl http://169.254.169.254/latest/meta-data/hostname)
+sed -i "s/NODE_NAME/$full_hostname/g" /tmp/node.yaml
+sed -i "s/TOKEN/$token/g" /tmp/node.yaml
+sed -i "s/HASHES/$hashes/g" /tmp/node.yaml
+sudo kubeadm join --config /tmp/node.yaml


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org