带你开启 Kubernetes 的云端之旅 周琦,AWS 解决方案架构师
演讲日程 AWS 容器平台发展历程 AWS 上运行 Kubernetes 集群的选择 什么是 Amazon EKS? Amazon EKS 架构介绍 通过 Amazon EKS 创建你的第一个托管 Kubernetes 集群
AWS 容器管理平台的前世今生 客户 实验, 更新, 发布新服务 发布 反馈 / 新用户案例 50+ 2015 后超过 50 次的更新 AWS 理解与学习
Amazon ECS(Elastic Container Service) AWS 2015 年推出的第一款云中托管的容器集群管理服务 awsvpc 网络模式进阶的任务置放策略深度集成 AWS 相关服务 ECS CLI 全球部署 强力的编排引擎 自动扩展组 Amazon CloudWatch 监控指标 负载均衡器
AWS Fargate 让客户专注于开发应用 无需管理基础设施 围绕任务为中心的原生 API 基于实际的任务资源计费
开发者青睐 Kubernetes 自有数据中心 CLOUD 云计算 可扩展 服务广度 性能
AWS 是众多客户首选的容器应用技术平台 57% CNCF of Kubernetes workloads run on AWS today survey https://www.cncf.io/blog/2017/12/06/cloud-native-technologies-scaling-productionapplications/
Kubernetes Cluster 搭建的选择 开发测试环境 Minikube 开源社区 Kops List: kubernetes-aws.io 企业级 Rancher CoreOS Tectonic Red Hat OpenShift 自定义 CloudFormation Terraform APN 合作伙伴 : Docker, Heptio, Mesosphere
通过 Kops 管理 Kubernetes 集群 github.com/kubernetes/kops export AWS_AVAILABILITY_ZONES=${ZONES:-"us-east-1b,us-east-1c,us-east- 1d"} export KOPS_STATE_STORE="s3://kubernetes-aws-io" kops create cluster cluster.k8s.local \ --master-count 3 \ --master-size m4.large \ --node-count 5 \ --node-size m4.large \ --zones $AWS_AVAILABILITY_ZONES \ --networking calico \ --yes
AWS 上自建 Kubernetes 集群典型架构 Master Master Master Etcd Etcd Etcd Worker 可用区 1 可用区 2 可用区 3
Amazon EKS (Elastic Container Service for Kubernetes) 和开源 Kubernetes 一致体验 Upstream 保持和上游同步 支持企业生产级别的容器应用 按需和 AWS 服务无缝集成
Amazon EKS 集群典型架构 Master Master Master AWS Managed AWS 托管 Workers Workers Workers Customer Account 客户账号 可用区 1 可用区 2 可用区 3
如何访问 Amazon EKS 集群 Kubectl mycluster.eks.amazonaws.com 可用区 1 可用区 2 可用区 3
Amazon EKS 用户体验 创建 Amazon EKS 集群 启动 K8S 插件 创建并添加 Worker 节点 启动容器应用
Amazon EKS Master 节点创建过程 创建 Master 创建高可用的 Master 集群 创建高可用的 etcd 集群 集成 IAM 认证授权 证书管理 弹性伸缩 创建和配置负载均衡
Amazon EKS Master 节点弹性伸缩 Master AWS CloudTrail Amazon CloudWatch Amazon EKS 监控 Master 节点的性能指标, 并在必要时进行扩展, 保证 Kubernetes 集群控制平面的高可用性 通过 Amazon CloudTrail 记录 EKS API 调用, Kubernetes Master 节点日志可以通过 CloudWatch 获得
支持 Kubernetes 集群的 Amazon VPC CNI 网络插件 { } 原生的网络模型通过 CNI 插件支持 K8S Pods 拥有和 VPC 中节点 Nodes) 一样的 VPC 网络地址 简单 安全 高效的网络模型 Github 开源 h t t p s : / / g i t h u b. c o m / a w s / a m a z o n - v p c - c n i - k 8 s
可以用在哪些 Kubernetes 场景? 任何运行在 AWS 上的 Kubernetes 集群 : Amazon EKS BYO Kubernetes Daemonset 方式部署 kubectl create f eks-cni.yaml
基于 Amazon VPC CNI 网络插件连接过程 ec2.associateaddress() Nginx Pod Veth IP: 10.0.0.1 Secondary IPs: 10.0.0.20 10.0.0.22 ENI Nginx Pod Veth IP: 10.0.0.20 Java Pod Veth IP: 10.0.0.2 ENI Secondary IPs: 10.0.0.1 10.0.0.2 实例 1 VPC Subnet 实例 2 10.0.0.0/24 Java Pod Veth IP: 10.0.0.22
Amazon EKS 如何保障网络安全? Kubernetes 网络策略定义基于网络安全规则的访问控制 Calico 是目前领先的网络策略 API 接口的实现方案 开源, 活跃的社区 (>100 贡献者 ) Tigera 可提供商业支持 https://docs.aws.amazon.com/zh_cn/eks/latest/userguide/calico.html
Kubernetes 集成 AWS IAM 认证授权 AWS 原生的访问控制 和 Heptio 合作开发 支持 Kubectl 和 Worker 节点的认证授权 兼容 Kubernetes RBAC
用户认证和授权过程 1) Passes AWS Identity 2) Verifies AWS Identity Kubectl 4) K8s action allowed/denied K8s API AWS Auth 3) Authorizes AWS Identity with RBAC
Kubernetes 集群的可视化 Cluster Node Container Application
Amazon EKS 日志管理 日志 Amazon CloudWatch Logs Master Worker Worker Fluentd DaemonSet AZ1 Kubectl logs Elasticsearch ( 索引 ), Fluentd ( 存储 ), 以及 Kibana ( 可视化 ) Amazon ElasticSearch Service Kibana Master ASG Worker Worker ASG AZ2 Region https://github.com/aws-samples/aws-workshop-for-kubernetes/tree/master/02-path-workingwith-clusters/204-cluster-logging-with-efk
可选择的自动升级配置 Version 1.10 1.9.2 1.9.1 Version 1.9
Amazon EKS 节点弹性伸缩 (Cluster-Autoscaler) Kubectl mycluster.eks.amazonaws.com Cluster-autoscaler addon 与 ASG 结合实现 worker nodes 节点扩展 EC2 Spot On-Demand EC2 On-Demand EC2 Worker nodes 可以选择 On-Demand 或者 Amazon EC2 Spot 节点注册在 Amazon EKS 集群中 可用区 1 可用区 2 可用区 3
Amazon EKS Ingress 选择 (ELB/NLB) EC2 instances Nginx Pods 1) Request to NGINX Pod {NLB}:443 2) NLB Forwards to the node {node:32001} 10001:8080 Internet NLB kube-proxy :32001 nginx-service :32002 10002:8080 3) Proxies request to the k8s service 4) Load Balances to pods 10003:8080
Amazon EKS Ingress 选择 (ALB) EC2 instances 1) Request to NGINX Pod {ALB}:443 2) ALB Routes based on the path. /api kube-proxy :32001 nginx-service :32003 Nginx Pods 10002:8080 Webapp Pods ALB /home kube-proxy :32002 3) Proxies request to the k8s service webapp-service :32004 4) Load Balances to pods 10002:8080
Amazon EKS 的 APN 合作伙伴生态体系
Amazon EKS 客户案例
未来由你选择 Amazon ECS Amazon EKS 1. 选择需要的编排工具. 2. 选择需要的运行模式. Amazon EC2 AWS Fargate Amazon EC2 AWS Fargate
创建第一个 Amazon EKS 集群
创建集群环境的先决条件 创建您的 Amazon EKS 服务角色 创建您的 Amazon EKS 集群 VPC 及 Security Group 为 Amazon EKS 安装 kubectl 为 Amazon EKS 安装 heptio-authenticator-aws 安装最新版本的 AWS CLI Amazon EKS 至少需要版本 1.15.32 的 AWS CLI 系统的 Python 版本必须为 Python 3 或 Python 2.7.9 或更高版本 请参考 : https://docs.aws.amazon.com/zh_cn/eks/latest/userguide/getting-started.html
创建第一个 Amazon EKS 集群 aws eks create-cluster cluster-name innovate2018 desired-master-version 1.10 role-arn arn:aws:iam::account-id:role/role-name subnetids=subnetid,securitygroupids=security-group-id
获取 endpoint 及 certificateauthority 信息 aws eks describe-cluster -name innovate2018
为新创建的 Amazon EKS 集群配置 Kubectl 创建 Kubeconfig 文件 将该文件保存到 ~/.kube/config-<cluster-name> 将该文件路径添加到 KUBECONFIG 环境变量 export KUBECONFIG=$KUBECONFIG:~/.kube/config-<clustername> echo 'export KUBECONFIG=$KUBECONFIG:~/.kube/config- <cluster-name>' >> ~/.bash_profile
启动和配置 Amazon EKS 的 Worker Nodes 通过 Amazon CloudFormation 模板创建 Worker Nodes https://amazon- eks.s3-us-west- 2.amazonaws.com/1.10.3/2018-06- 05/amazon-eksnodegroup.yaml
kubectl get nodes aws eks delete-cluster -name innovate2018
相关链接 快速开始使用 Amazon EKS 官网链接 : http://aws.amazon.com/eks Kubernetes Workshop https://github.com/aws-samples/aws-workshop-for-kubernetes
感谢参加 AWS INNOVATE 2018 在线技术大会 我们希望您在这里找到感兴趣的内容! 也请帮助我们完成投票打分和反馈问卷 欲获取关于 AWS 的更多信息和技术内容, 可以通过以下方式找到我们 : 微信公众号 :AWSChina 新浪微博 :https://www.weibo.com/amazonaws/ 领英 :https://www.linkedin.com/company/aws-china/ 知乎 :https://www.zhihu.com/org/aws-54/activities/ 视频中心 :http://aws.amazon.bokecc.com/ 更多线上活动 :https://aws.amazon.com/cn/about-aws/events/webinar/