Skip to content

Instantly share code, notes, and snippets.

@gowatana
Last active March 17, 2021 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gowatana/91a91818d61f0c3c735acd7e75e8b7fa to your computer and use it in GitHub Desktop.
Save gowatana/91a91818d61f0c3c735acd7e75e8b7fa to your computer and use it in GitHub Desktop.
Nutanix AHV の Custom Script(Cloud-Init)で kubectl むけ VM を作成する。
#cloud-config
disable_root: true
ssh_pwauth: true
package_upgrade: false
users:
- name: nutanix
lock-passwd: false
passwd: $6$oDzrtJla$rMzS0vuH95Q2PjDgqVOsI30MqAYemPK5Y9uYsSpeQWd99R4hqm/JWoJqH4Y81SlbtTMkglp243leccceKNZ9h.
sudo: ALL=(ALL) NOPASSWD:ALL
packages:
- git
- unzip
- bash-completion
runcmd:
- mkdir /home/nutanix/bin
- curl -L -o /home/nutanix/bin/kubectl "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
- chmod +x /home/nutanix/bin/kubectl
- echo 'source <(kubectl completion bash)' >> /home/nutanix/.bash_profile
- chown -R nutanix:nutanix /home/nutanix/bin
@gowatana
Copy link
Author

利用例

  • CVM にログインして実行する。
  • イメージ サービスに CentOS-7-x86_64-GenericCloud-2003.qcow2 登録ずみ。
  • vlan-6-ipam ネットワークを、IPAM 有効で作成ずみ。
$ VMNAME=lab-vm-01
$ acli uhura.vm.create_with_customize $VMNAME num_vcpus=1 memory=2G cloudinit_userdata_path=https://gist.githubusercontent.com/gowatana/91a91818d61f0c3c735acd7e75e8b7fa/raw/kubectl-centos7-vm.yml
$ acli vm.disk_create $VMNAME clone_from_image=CentOS-7-x86_64-GenericCloud-2003
$ acli vm.nic_create $VMNAME network=vlan-6-ipam
$ acli vm.on $VMNAME

VM が起動したら下記で SSH ログインする。IP アドレスは、AOS の IPAM による DHCP 自動設定。

  • ユーザ: nutanix
  • パスワード: nutanix/4u

@gowatana
Copy link
Author

AHV VM での Custom Script を acli ではなくPrism から利用する様子
https://blog.ntnx.jp/entry/2020/08/30/153906

@gowatana
Copy link
Author

gowatana commented Mar 17, 2021

cloud-init 導入済みの CentOS7 OS ディスク イメージを、CVM の acli コマンドでダウンロード&登録するコマンドライン例。

  • ストレージ コンテナ名「default-container-XXXX」は、環境に合わせて変更する。
$ acli image.create CentOS-7-x86_64-GenericCloud-2003 image_type=kDiskImage container=default-container-XXXX source_url=https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2003.qcow2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment