LoginSignup
0
1

More than 5 years have passed since last update.

tectonic で kubernetes クラスタを構築・管理する(AWS)

Posted at

概要

tectonic で AWS に kubernetes クラスタを構築する。

対応プラットフォーム(2017.06.09 時点)
  • AWS
  • Bare Metal
  • Microsoft Azure (alpha)
  • OpenStack (pre-alpha)
料金
  • 10ノードまで無料

環境

インストーラを実行した環境
- Amazon Linux AMI 2017.03
- tectonic 1.6.4

事前準備

セットアップ前に必要な作業

  • CoreOS
    • CoreOS アカウントサインアップ
    • CoreOS License 取得 (tectonic-license.txt)
    • Secret 取得 (config.json)
  • AWS
    • IAM Role 設定 (Policy)
    • Route 53 でパブリックホストゾーンの作成

tectonic のインストーラー取得

ダウンロード・解凍

$ wget https://releases.tectonic.com/tectonic-1.6.4-tectonic.1.tar.gz
$ tar xzvf tectonic-1.6.4-tectonic.1.tar.gz
$ cd tectonic

tectonic セットアップ (GUI)

インストーラー起動

$ ./tectonic-installer/linux/installer -address=0.0.0.0:4444 -open-browser=false
Starting Tectonic Installer on 0.0.0.0:4444

ブラウザで インストーラーを起動したホストIPアドレス:4444 にアクセスして、画面に従いセットアップする

01.png

tectonic セットアップ (terraform)

インストーラーの環境設定

$ export INSTALLER_PATH=$(pwd)/tectonic-installer/linux/installer
$ export PATH=$PATH:$(pwd)/tectonic-installer/linux

terraform 環境設定

$ sed "s|<PATH_TO_INSTALLER>|$INSTALLER_PATH|g" terraformrc.example > .terraformrc
$ export TERRAFORM_CONFIG=$(pwd)/.terraformrc

cluster resources 取得

$ terraform get platforms/aws

credential を環境変数に設定

$ export AWS_ACCESS_KEY_ID=AK***************
$ export AWS_SECRET_ACCESS_KEY=**************************************
$ export AWS_REGION=ap-northeast-1

クラスタ設定

クラスタ名を設定

$ export CLUSTER=cluster-1

クラスタ環境設定

$ mkdir -p build/${CLUSTER}
$ cp examples/terraform.tfvars.aws build/${CLUSTER}/terraform.tfvars

terraform 環境設定

$ vi build/cluster-1/terraform.tfvars

設定内容

tectonic_admin_email = "********************"   #tectonic console ログインID
tectonic_admin_password_hash = "*************"  #ログインパスワード※

tectonic_aws_az_count = "1"
tectonic_aws_region = "ap-northeast-1"
tectonic_aws_ssh_key = "************"           #AWS に登録した Key pair

tectonic_base_domain = "*************"          #Route 53 に登録したドメイン
tectonic_cluster_name = "cluster-1"             #クラスタ名

tectonic_license_path = "/path/to/tectonic-license.txt" #事前に取得した CoreOS Lisence
tectonic_pull_secret_path = "/path/to/config.json"      #事前に取得した CoreOS Secret

tectonic_worker_count = "2"                     #worker ノード数

tectonic_admin_password_hash は bcrypt で hash 化する (bcrypt-hash tool)

$ wget https://github.com/coreos/bcrypt-tool/releases/download/v1.0.0/bcrypt-tool-v1.0.0-linux-amd64.tar.gz
$ tar zxvf bcrypt-tool-v1.0.0-linux-amd64.tar.gz
$ ./bcrypt-tool/bcrypt-tool 
Enter password: 
Re-enter password: 
$2a$10$*****************************************************

plan 実行

$ terraform plan -var-file=build/${CLUSTER}/terraform.tfvars platforms/aws
Plan: 116 to add, 0 to change, 0 to destroy.

クラスタをデプロイ

apply 実行

$ terraform apply -var-file=build/${CLUSTER}/terraform.tfvars platforms/aws

クラスタへのアクセス

作成された kubeconfig を読み込み

$ export KUBECONFIG=generated/auth/kubeconfig

クラスタ確認

$ kubectl cluster-info
Kubernetes master is running at https://cluster-1-api.***.****.jp:443
KubeDNS is running at https://cluster-1-api.***.****.jp:443/api/v1/proxy/namespaces/kube-system/services/kube-dns

ノード確認

$ kubectl get node
NAME                                             STATUS    AGE       VERSION
ip-10-0-22-59.ap-northeast-1.compute.internal    Ready     4m        v1.6.4+coreos.0
ip-10-0-37-60.ap-northeast-1.compute.internal    Ready     2m        v1.6.4+coreos.0
ip-10-0-52-127.ap-northeast-1.compute.internal   Ready     1m        v1.6.4+coreos.0

tectonic console にアクセス

ブラウザで https://{{ tectoniccluster_name }}.{{ tectonic_base_domain }}/ にアクセス

12.png

設定したログインID、パスワードでログインする

13.png

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1