aws(学习笔记第二十八课) aws eks使用练习(hands on)

aws(学习笔记第二十八课)

  • 使用aws eks

学习内容:

  • 什么是aws eks
  • aws ekshands on
  • aws eks的创建application
  • ekskubernetes简介

1. 使用aws eks

  1. 什么是aws eks

    • aws eks的概念
      aws ekskubernetesaws上包装出来 的新的方式,旨在更加方便结合aws,在aws上使用 kubernetes。实际上aws eksaws上的managed service。作为执行containerserver来说,可以使用EC2或者Fargate都是可以的。
    • aws eksECS的区别
      区别在于orchestration tool‌的不同,aws eks使用的kubernetes作为orchestration tool‌,如果onpromise上使用的是kubernetes,那么同样的架构能够在aws同样使用。
      ECS使用的orchestration tool‌aws独自的,智能在aws上使用。
    • 什么是orchestration tool‌
      orchestration tool‌是指一种用于协调和管理系统资源、服务和应用程序的工具,以确保它们能够高效、可靠地运行。这种工具通常用于自动化和优化资源的分配和管理,特别是在云计算和容器化环境中。
  2. aws eks的架构
    在这里插入图片描述

  3. aws上的示例程序
    aws上提供了示例程序,能够使用练习eks
    eks的示例程序

2. aws ekshands on

  1. 环境(软件安装)准备
    • 练习用的ec2
      这里依然采用方便的cloudshell进行练习
    • aws cli的版本确认
      aws --version
      
    • 安装eksctl
      curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
      eksctl version
      
    • 安装kubectl
      如果使用cloudshell,不用安装kubectl,如果使用的EC2,那么执行下面的命令。
      curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.18.8/2020-09-18/bin/linux/amd64/kubectl
      chmod +x ./kubectl
      sudo mv ./kubectl /usr/local/bin
      kubectl version --client
      
  2. 对于需要的权限设定role进行作成
    • eksClusterRole的创建
      这里的role主要是赋予给eks服务足够的权利。role的名字是eksClusterRole
      保存到文件,之后使用cloudformation进行创建role的操作。
      AWSTemplateFormatVersion: '2010-09-09'
      Description: 'Amazon EKS Cluster Role'
      
      Resources:
        eksClusterRole:
          Type: 'AWS::IAM::Role'
          Properties:
            AssumeRolePolicyDocument:
              Version: '2012-10-17'
              Statement:
                - Effect: Allow
                  Principal:
                    Service:
                      - eks.amazonaws.com
                  Action:
                    - sts:AssumeRole
            ManagedPolicyArns:
              - arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
      
      Outputs:
        RoleArn:
          Description: 'The role that Amazon EKS will use to create AWS resources for Kubernetes clusters'
          Value: !GetAtt eksClusterRole.Arn
          Export:
            Name: !Sub '${AWS::StackName}-RoleArn'
      
    • eks-nodegroup-role的创建
      还需要创建work node的需要的权限role,这个代码由aws提供。
      -> aws work node role link
    AWSTemplateFormatVersion: "2010-09-09"
    
    Description: Amazon EKS - Node Group Role
    
    Mappings:
      ServicePrincipals:
        aws-cn:
          ec2: ec2.amazonaws.com.cn
        aws-us-gov:
          ec2: ec2.amazonaws.com
        aws:
          ec2: ec2.amazonaws.com
    
    Resources:
      NodeInstanceRole:
        Type: "AWS::IAM::Role"
        Properties:
          AssumeRolePolicyDocument:
            Version: "2012-10-17"
            Statement:
              - Effect: Allow
                Principal:
                  Service:
                    - !FindInMap [ServicePrincipals, !Ref "AWS::Partition", ec2]
                Action:
                  - "sts:AssumeRole"
          ManagedPolicyArns:
            - !Sub "arn:${AWS::Partition}:iam::aws:policy/AmazonEKSWorkerNodePolicy"
            - !Sub "arn:${AWS::Partition}:iam::aws:policy/AmazonEKS_CNI_Policy"
            - !Sub "arn:${AWS::Partition}:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
          Path: /
    
    Outputs:
      NodeInstanceRole:
        Description: The node instance role
        Value: !GetAtt NodeInstanceRole.Arn
    
  3. 创建eks所在的vpc
    • 使用cloudformation来创建vpc
      这个vpc的创建jsonaws提供示例代码。->eks所在的vpc示例json
      这里在subnet指定采用了hardcoding,如果不进行hardcoding发现总是提示错误,暂定对应。
      ---
      AWSTemplateFormatVersion: '2010-09-09'
      Description: 'Amazon EKS Sample VPC - Public subnets only'
      
      Parameters:
      
        VpcBlock:
          Type: String
          Default: 192.168.0.0/16
          Description: The CIDR range for the VPC. This should be a valid private (RFC 1918) CIDR range.
      
        Subnet01Block:
          Type: String
          Default: 192.168.64.0/18
          Description: CidrBlock for subnet 01 within the VPC
      
        Subnet02Block:
          Type: String
          Default: 192.168.128.0/18
          Description: CidrBlock for subnet 02 within the VPC
      
        Subnet03Block:
          Type: String
          Default: 192.168.192.0/18
          Description: CidrBlock for subnet 03 within the VPC. This is used only if the region has more than 2 AZs.
      
      Metadata:
        AWS::CloudFormation::Interface:
          ParameterGroups:
            -
              Label:
                default: "Worker Network Configuration"
              Parameters:
                - VpcBlock
                - Subnet01Block
                - Subnet02Block
                - Subnet03Block
      
      Conditions:
        Has2Azs:
          Fn::Or:
            - Fn::Equals:
              - {Ref: 'AWS::Region'}
              - ap-south-1
            - Fn::Equals:
              - {Ref: 'AWS::Region'}
              - ap-northeast-2
            - Fn::Equals:
              - {Ref: 'AWS::Region'}
              - ca-central-1
            - Fn::Equals:
              - {Ref: 'AWS::Region'}
              - cn-north-1
            - Fn::Equals:
              - {Ref: 'AWS::Region'}
              - sa-east-1
            - Fn::Equals:
              - {Ref: 'AWS::Region'}
              - us-west-1
      
        HasMoreThan2Azs:
          Fn::Not:
            - Condition: Has2Azs
      
      Resources:
        VPC:
          Type: AWS::EC2::VPC
          Properties:
            CidrBlock:  !Ref VpcBlock
            EnableDnsSupport: true
            EnableDnsHostnames: true
            Tags:
            - Key: Name
              Value: !Sub '${AWS::StackName}-VPC'
      
        InternetGateway:
          Type: "AWS::EC2::InternetGateway"
      
        VPCGatewayAttachment:
          Type: "AWS::EC2::VPCGatewayAttachment"
          Properties:
            InternetGatewayId: !Ref InternetGateway
            VpcId: !Ref VPC
      
        RouteTable:
          Type: AWS::EC2::RouteTable
          Properties:
            VpcId: !Ref VPC
            Tags:
            - Key: Name
              Value: Public Subnets
            - Key: Network
              Value: Public
      
        Route:
          DependsOn: VPCGatewayAttachment
          Type: AWS::EC2::Route
          Properties:
            RouteTableId: !Ref RouteTable
            DestinationCidrBlock: 0.0.0.0/0
            GatewayId: !Ref InternetGateway
      
        Subnet01:
          Type: AWS::EC2::Subnet
          Metadata:
            Comment: Subnet 01
          Properties:
            MapPublicIpOnLaunch: true
            AvailabilityZone:  ap-northeast-1a
            CidrBlock:
              Ref: Subnet01Block
            VpcId:
              Ref: VPC
            Tags:
            - Key: Name
              Value: !Sub "${AWS::StackName}-Subnet01"
            - Key: kubernetes.io/role/elb
              Value: 1
      
        Subnet02:
          Type: AWS::EC2::Subnet
          Metadata:
            Comment: Subnet 02
          Properties:
            MapPublicIpOnLaunch: true
            AvailabilityZone: ap-northeast-1c
            CidrBlock:
              Ref: Subnet02Block
            VpcId:
              Ref: VPC
            Tags:
            - Key: Name
              Value: !Sub "${AWS::StackName}-Subnet02"
            - Key: kubernetes.io/role/elb
              Value: 1
      
        Subnet03:
          Condition: HasMoreThan2Azs
          Type: AWS::EC2::Subnet
          Metadata:
            Comment: Subnet 03
          Properties:
            MapPublicIpOnLaunch: true
            AvailabilityZone:  ap-northeast-1d
            CidrBlock:
              Ref: Subnet03Block
            VpcId:
              Ref: VPC
            Tags:
            - Key: Name
              Value: !Sub "${AWS::StackName}-Subnet03"
            - Key: kubernetes.io/role/elb
              Value: 1
      
        Subnet01RouteTableAssociation:
          Type: AWS::EC2::SubnetRouteTableAssociation
          Properties:
            SubnetId: !Ref Subnet01
            RouteTableId: !Ref RouteTable
      
        Subnet02RouteTableAssociation:
          Type: AWS::EC2::SubnetRouteTableAssociation
          Properties:
            SubnetId: !Ref Subnet02
            RouteTableId: !Ref RouteTable
      
        Subnet03RouteTableAssociation:
          Condition: HasMoreThan2Azs
          Type: AWS::EC2::SubnetRouteTableAssociation
          Properties:
            SubnetId: !Ref Subnet03
            RouteTableId: !Ref RouteTable
      
        ControlPlaneSecurityGroup:
          Type: AWS::EC2::SecurityGroup
          Properties:
            GroupDescription: Cluster communication with worker nodes
            VpcId: !Ref VPC
      
      Outputs:
      
        SubnetIds:
          Description: All subnets in the VPC
          Value:
            Fn::If:
            - HasMoreThan2Azs
            - !Join [ ",", [ !Ref Subnet01, !Ref Subnet02, !Ref Subnet03 ] ]
            - !Join [ ",", [ !Ref Subnet01, !Ref Subnet02 ] ]
      
        SecurityGroups:
          Description: Security group for the cluster control plane communication with worker nodes
          Value: !Join [ ",", [ !Ref ControlPlaneSecurityGroup ] ]
      
        VpcId:
          Description: The VPC Id
          Value: !Ref VPC
      
  4. eks所在的vpc中创建eks cluster
    • 选择自定义配置
      注意,这里千万不要选择EKS自治模式-全新,如果选择,后面创建的work node会出现错误!在这里插入图片描述

    • 设定cluster名字和role
      这里设定eks-clusterrole选择上面创建的eksClusterRole
      在这里插入图片描述

    • 设置IAM角色
      这里设置administor的权限,ec-role
      在这里插入图片描述

    • ec2-role的权限设定
      在这里插入图片描述

    • 设置vpc
      这里设置前面已经创建的vpc
      在这里插入图片描述

    • 集群端点访问设定
      这里设置成public
      在这里插入图片描述

    • 等待cluster创建
      这里大概要等待10分钟
      在这里插入图片描述

  5. eks所在的cluster中创建kubeconfig
    • 作成kubeconfig文件
      如果不做成kubeconfig文件,无法访问eks cluster
      aws eks --region ap-northeast-1 update-kubeconfig --name eks-cluster
      
      在这里插入图片描述
  6. 尝试链接eks所在的cluster
    • 链接测试
      kubectl get svc
      
      在这里插入图片描述
  7. 作成eks cluster中的work node
    • 启动work node group
      在这里插入图片描述
    • 这是work node group的名字和IAM role
      这里设定的role就是前面创建的role。名字设置为work-node-group
      在这里插入图片描述
    • 设定ec2 type,节点数和磁盘大小
      在这里插入图片描述
    • 等待work node group创建,这里需要5分钟
      在这里插入图片描述
    • 检查ec2
      可以看到这里作成了三个ec2 instances
      在这里插入图片描述

3. aws eks的创建application

  1. 部署redis数据库

    • 使用下面的github上的官方sample程序
      redis-master-controller
      git clone https://github.com/kubernetes/examples.git
      cd examples/guestbook-go
      
    • 之后进入example文件夹,启动redis controller
      kubectl apply -f redis-master-controller.yaml
      
      在这里插入图片描述
    • 启动redis service
      kubectl apply -f redis-master-service.yaml
      
      在这里插入图片描述
  2. 部署guest-book服务

    1. 启动guest-book
      kubectl apply -f guestbook-controller.yaml
      kubectl apply -f guestbook-service.yaml
      
    2. 确定external ip
      kubectl get pod,svc -o wide
      
      这里看出external ip没有已经成功。
      [cloudshell-user@ip-10-132-94-203 guestbook-go]$ kubectl get pod,svc -o wide
      NAME                     READY   STATUS    RESTARTS   AGE   IP                NODE                                                 NOMINATED NODE   READINESS GATES
      pod/guestbook-fpcrt      1/1     Running   0          36s   192.168.140.31    ip-192-168-187-37.ap-northeast-1.compute.internal    <none>           <none>
      pod/guestbook-gm9sh      1/1     Running   0          36s   192.168.115.254   ip-192-168-101-164.ap-northeast-1.compute.internal   <none>           <none>
      pod/guestbook-l8hkb      1/1     Running   0          36s   192.168.200.226   ip-192-168-226-52.ap-northeast-1.compute.internal    <none>           <none>
      pod/redis-master-tl8wh   1/1     Running   0          70s   192.168.190.37    ip-192-168-187-37.ap-northeast-1.compute.internal    <none>           <none>
      
      NAME                   TYPE           CLUSTER-IP       EXTERNAL-IP                                                                    PORT(S)          AGE    SELECTOR
      service/guestbook      LoadBalancer   10.100.160.68    a2a85261d601c46049d98728d4861990-1486435799.ap-northeast-1.elb.amazonaws.com   3000:30560/TCP   26s    app=guestbook
      service/kubernetes     ClusterIP      10.100.0.1       <none>                                                                         443/TCP          169m   <none>
      service/redis-master   ClusterIP      10.100.153.210   <none>                                                                         6379/TCP         49s    app=redis,role=master
      
  3. 访问guest-book服务

    http://a2a85261d601c46049d98728d4861990-1486435799.ap-northeast-1.elb.amazonaws.com:3000
    

    guest-book服务启动成功。在这里插入图片描述

4. aws ekskubernetes简介

  1. 关于 aws ekskubernetes
    EKS(Elastic Kubernetes Service)就是aws提供的managed Kubenetes服务。通过awsmanaged封装,能够便利的管理Kubenetes服务,减轻运用的负担。并且,通过awsmanaged服务,更好的利用kubenetes提供的各种resource
    Kubenetes(K8S)是Google公司开发的Borg项目为基础的OSS(Open Source Software)Kubenetes(K8S)能够对container化的应用程序进行部署(deploy),自动的scaling,并且进行管理。非常多的云(cloud)提供商的系统本身就是使用的Kubenetes
    以下是Kubenetes的整体架构。
    在这里插入图片描述

  2. 什么是Control Plain(master node)
    Control Plain(master node)就是集群cluster内部的work nodecontainer管理的节点node。在eks cluster之后存在着两种节点。

    • Control Plain(master node)
    • work node

    Control Plain(master node)保持着kubernetes中对象的状态,接受从client来的command,进行API Action的执行,进行container部署。或者,schdulerControl Plain(master node)进行动作,通知work node上的kubelet(agent)进行动作。kubelet(agent),接受Control plain(master)的指示启动container

  3. 什么是work node
    work node就是实际上就是接受Control Plain(master node) 的指示,启动containerwork node既可以选择ec2,也可以选择fargate

  4. aws eks的构成

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/970594.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

解读 Flink Source 接口重构后的 KafkaSource

前言 Apache Kafka 和 Apache Flink 的结合&#xff0c;为构建实时流处理应用提供了一套强大的解决方案[1]。Kafka 作为高吞吐量、低延迟的分布式消息队列&#xff0c;负责数据的采集、缓冲和分发&#xff1b;而 Flink 则是功能强大的流处理引擎&#xff0c;负责对数据进行实时…

deepseek多列数据对比,联想到excel的高级筛选功能

目录 1 业务背景 ​2 deepseek提示词输入 ​3 联想分析 4 EXCEL高级搜索 1 业务背景 系统上线的时候经常会遇到一个问题&#xff0c;系统导入的数据和线下的EXCEL数据是否一致&#xff0c;如果不一致&#xff0c;如何快速找到差异值&#xff0c;原来脑海第一反应就是使用公…

ubuntu20.04声音设置

step1&#xff1a;打开pavucontrol&#xff0c;设置Configuration和Output Devices&#xff0c; 注意需要有HDMI / DisplayPort (plugged in)这个图标。如果没有&#xff0c;就先选择Configuration -> Digital Stereo (HDMI 7) Output (unplugged) (unvailable)&#xff0c;…

uniapp可视化-活动报名表单系统-代码生成器

活动报名表单系统小程序旨在为各类活动组织者提供一个便捷、高效的线上报名管理平台&#xff0c;同时为参与者提供简单易用的报名途径。 主要功能 活动发布&#xff1a;活动组织者可以发布活动的详细信息&#xff0c;包括活动名称、时间、地点、活动内容等。用户可以在小程序中…

DeepSeek 助力 Vue 开发:打造丝滑的无限滚动(Infinite Scroll)

前言&#xff1a;哈喽&#xff0c;大家好&#xff0c;今天给大家分享一篇文章&#xff01;并提供具体代码帮助大家深入理解&#xff0c;彻底掌握&#xff01;创作不易&#xff0c;如果能帮助到大家或者给大家一些灵感和启发&#xff0c;欢迎收藏关注哦 &#x1f495; 目录 Deep…

SpringBoot+shardingsphere实现按月分表功能

SpringBootshardingsphere实现按月分表功能 文章目录 前言 ShardingSphere 是一套开源的分布式数据库中间件解决方案&#xff0c;旨在简化数据库分片、读写分离、分布式事务等复杂场景的管理。它由 Apache 软件基金会支持&#xff0c;广泛应用于需要处理大规模数据的系统中 一…

大模型训练为什么依赖GPU

近年来&#xff0c;随着人工智能技术的飞速发展&#xff0c;特别是深度学习领域的进步&#xff0c;大模型的训练逐渐成为研究和工业界的热点。作为大模型训练中的核心硬件&#xff0c;GPU&#xff08;图形处理单元&#xff09;扮演了至关重要的角色。那么&#xff0c;为什么大模…

SQL布尔盲注+时间盲注

1.布尔盲注 双重for循环 import requestsurl http://127.0.0.1/sqli-labs-master/Less-8/index.phpdef database_name():datebasename for i in range(1, 9): # 假设数据库名称最多8个字符for j in range(32, 128): # ascii 可见字符范围从32到127payload f"?id1 A…

收银系统源码开发指南:PHP + Flutter + Uniapp 全栈方案

收银系统一般涵盖了收银POS端、线上商城端和管理端&#xff0c;技术栈涉及PHP、Flutter和Uniapp。为了确保系统的稳定运行和持续发展&#xff0c;在开发和运营过程中需要重点关注以下几个方面&#xff1a; 一、系统架构与性能优化 模块化设计: 将系统拆分为独立的模块&#xf…

springCloud-2021.0.9 之 GateWay 示例

文章目录 前言springCloud-2021.0.9 之 GateWay 示例1. GateWay 官网2. GateWay 三个关键名称3. GateWay 工作原理的高级概述4. 示例4.1. POM4.2. 启动类4.3. 过滤器4.4. 配置 5. 启动/测试 前言 如果您觉得有用的话&#xff0c;记得给博主点个赞&#xff0c;评论&#xff0c;收…

Vue.js 在低代码开发平台中的应用与优化

Vue.js 在低代码开发平台中的应用与优化 在数字化转型的进程中&#xff0c;低代码开发平台成为了企业快速构建应用的得力助手。而 Vue.js 作为一款广受欢迎的前端框架&#xff0c;在低代码开发平台中发挥着举足轻重的作用。它不仅提升了开发效率&#xff0c;还优化了应用的用户…

大模型Deepseek的使用_基于阿里云百炼和Chatbox

目录 前言1. 云服务商2. ChatBox参考 前言 上篇博文中探索了&#xff08;本地&#xff09;部署大语言模型&#xff0c;适合微调、数据高隐私性等场景。随着Deepseek-R1的发布&#xff0c;大语言模型的可及性得到极大提升&#xff0c;应用场景不断增加&#xff0c;对高可用的方…

Android设备 网络安全检测

八、网络与安全机制 6.1 网络框架对比 volley&#xff1a; 功能 基于HttpUrlConnection;封装了UIL图片加载框架&#xff0c;支持图片加载;网络请求的排序、优先级处理缓存;多级别取消请求;Activity和生命周期的联动&#xff08;Activity结束生命周期同时取消所有网络请求 …

[免费]SpringBoot公益众筹爱心捐赠系统【论文+源码+SQL脚本】

大家好&#xff0c;我是老师&#xff0c;看到一个不错的SpringBoot公益众筹爱心捐赠系统&#xff0c;分享下哈。 项目介绍 公益捐助平台的发展背景可以追溯到几十年前&#xff0c;当时人们已经开始通过各种渠道进行公益捐助。随着互联网的普及&#xff0c;本文旨在探讨公益事业…

zyNo.23

SQL注入漏洞 1.SQL语句基础知识 一个数据库由多个表空间组成&#xff0c;sql注入关系到关系型数据库&#xff0c;常见的关系型数据库有MySQL,Postgres,SQLServer,Oracle等 以Mysql为例&#xff0c;输入 mysql-u用户名-p密码 即可登录到MySQL交互式命令行界面。 既然是…

基于大数据的北京市天气数据分析系统的设计与实现

【Flask】基于Flask的北京市天气数据分析系统的设计与实现&#xff08;完整系统源码开发笔记详细部署教程&#xff09;✅ 目录 一、项目简介二、项目界面展示三、项目视频展示 一、项目简介 该系统采用Python和Flask框架&#xff0c;结合Pandas、NumPy等数据处理库及Echarts进…

【linux】在 Linux 上部署 DeepSeek-r1:32/70b:解决下载中断问题

【linux】在 Linux 上部署 DeepSeek-r1:32/70b:解决下载中断问题 【承接商业广告,如需商业合作请+v17740568442】 文章目录 【linux】在 Linux 上部署 DeepSeek-r1:32/70b:解决下载中断问题问题描述:解决方法方法一:手动中断并重启下载方法二:使用 Bash 脚本自动化下载在…

深入解析操作系统控制台:阿里云Alibaba Cloud Linux(Alinux)的运维利器

作为一位个人开发者兼产品经理&#xff0c;我的工作日常紧密围绕着云资源的运维和管理。在这个过程中&#xff0c;操作系统扮演了至关重要的角色&#xff0c;而操作系统控制台则成为了我们进行系统管理的得力助手。本文将详细介绍阿里云的Alibaba Cloud Linux操作系统控制台的功…

一场因软件技术窃取引发的法律风暴

根据最高人民法院(2020)最高法知民终1101号真实案例改编 第一章&#xff1a;创新的种子 2004年&#xff0c;北京明远软件设计研究院&#xff08;后更名为“明远软件股份有限公司”&#xff0c;以下简称“明远”&#xff09;的办公室里&#xff0c;创始人杨原和技术总监何晨亮…

Python的那些事第二十二篇:基于 Python 的 Django 框架在 Web 开发中的应用研究

基于 Python 的 Django 框架在 Web 开发中的应用研究 摘要 Django 是一个基于 Python 的高级 Web 框架,以其开发效率高、安全性和可扩展性强等特点被广泛应用于现代 Web 开发。本文首先介绍了 Django 的基本架构和核心特性,然后通过一个实际的 Web 开发项目案例,展示了 Dj…