tack icon indicating copy to clipboard operation
tack copied to clipboard

Get Cloud-config from s3

Open yagonobre opened this issue 9 years ago • 5 comments
trafficstars

The Problem

Update k8s version need stop all machine and update the user-data

The Proposal

Use a shell script, as user-data, that get cloud-config file from s3 and run it.

In test I get the ssl in this shell script, not using systemd services and the time for launching a new instance decreased significantly.

Example of Cloud-config template:

resource "template_file" "cloud-config" {

  template = <<EOF
#!/bin/bash

#Get s3-get-presigned
/usr/bin/mkdir -p /opt/bin
/usr/bin/curl -L -o /opt/bin/s3-get-presigned-url https://github.com/kz8s/s3-get-presigned-url/releases/download/v0.1/s3-get-presigned-url_linux_amd64
/usr/bin/chmod +x /opt/bin/s3-get-presigned-url

#Get SSL
/usr/bin/mkdir -p /etc/kubernetes/ssl
/usr/bin/curl $(/opt/bin/s3-get-presigned-url ${ region } ${ bucket } ${ ssl-tar }) | tar xv -C /etc/kubernetes/ssl/

#Run Cloudinit
/usr/bin/coreos-cloudinit --from-url=$(/opt/bin/s3-get-presigned-url ${ region } ${ bucket } user-data/worker)


EOF

  vars {
    bucket = "${ var.bucket-prefix }"
    region = "${ var.region }"
    ssl-tar = "/ssl/k8s-worker.tar"
  }
}

@wellsie Could we use this approach?

yagonobre avatar Nov 11 '16 23:11 yagonobre

I was thinking maybe to keep k8s master/nodes manifest files in S3, pull them in when VM starts. That should allow an easy k8s version update, push new manifest files to S3, reboot VM one by one :)

rimusz avatar Nov 12 '16 11:11 rimusz

@rimusz Is exactly this that i want to do. It as working in my cluster now.

yagonobre avatar Nov 12 '16 15:11 yagonobre

@yagonobre would you mind to share the code? as that k8s upgrade story is so needed for prod clusters

rimusz avatar Nov 12 '16 15:11 rimusz

Yes. I plan to share it next week.

I'm working on automate the update process

yagonobre avatar Nov 12 '16 16:11 yagonobre

cool, ping me if you need any testing.

rimusz avatar Nov 12 '16 16:11 rimusz