kops 集群部署

    • 自动部署高可用的 kubernetes 集群
    • 支持从 kube-up 创建的集群升级到 kops 版本
    • dry-run 和自动幂等升级等基于状态同步模型
    • 支持自动生成 AWS CloudFormation 和 Terraform 配置
    • 支持自定义扩展 add-ons
    • 命令行自动补全

    首先需要安装 AWS CLI 并配置 IAM:

    1. pip install awscli
    2. # configure iam
    3. aws iam create-group --group-name kops
    4. aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonEC2FullAccess --group-name kops
    5. aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonRoute53FullAccess --group-name kops
    6. aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess --group-name kops
    7. aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonVPCFullAccess --group-name kops
    8. aws iam create-user --user-name kops
    9. aws iam add-user-to-group --user-name kops --group-name kops
    10. aws iam create-access-key --user-name kops
    11. # configure the aws client to use your new IAM user
    12. aws iam list-users # you should see a list of all your IAM users here
    13. # Because "aws configure" doesn't export these vars for kops to use, we export them now
    14. export AWS_ACCESS_KEY_ID=<access key>
    15. export AWS_SECRET_ACCESS_KEY=<secret key>

    创建 s3 存储 bucket

    1. aws s3api create-bucket --bucket clusters.dev.example.com --region us-east-1
    2. aws s3api put-bucket-versioning --bucket clusters.dev.example.com --versioning-configuration Status=Enabled

    当然,也可以部署一个高可用的集群

    1. kops create cluster \
    2. --node-count 3 \
    3. --zones us-west-2a,us-west-2b,us-west-2c \
    4. --node-size t2.medium \
    5. --master-size t2.medium \
    6. --topology private \
    7. hacluster.example.com
    1. # Create cluster in GCE.
    2. # This is an alpha feature.
    3. export KOPS_STATE_STORE="gs://mybucket-kops"
    4. export ZONES=${MASTER_ZONES:-"us-east1-b,us-east1-c,us-east1-d"}
    5. export KOPS_FEATURE_FLAGS=AlphaAllowGCE
    6. kops create cluster kubernetes-k8s-gce.example.com
    7. --zones $ZONES \
    8. --master-zones $ZONES \
    9. --node-count 3
    10. --project my-gce-project \
    11. --image "ubuntu-os-cloud/ubuntu-1604-xenial-v20170202" \