24sama
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # KubeKey 在 AWS 高可用部署 Kubernetes 对于生产环境,我们需要考虑集群的高可用性。本文教您部署如何在多台 AWS EC2 实例快速部署一套高可用的生产环境。要满足 Kubernetes 集群服务需要做到高可用,需要保证 kube-apiserver 的 HA ,可使用以下下列三种方式: * AWS ELB(推荐) * keepalived + haproxy [keepalived + haproxy](https://kubesphere.com.cn/forum/d/1566-kubernetes-keepalived-haproxy)对 kube-apiserver 进行负载均衡,实现高可用 Kubernetes 集群。 本教程重点介绍配置 AWS ELB 服务高可用安装。 ## 前提条件 - 考虑到数据的持久性,对于生产环境,我们不建议您使用存储OpenEBS,建议 NFS、GlusterFS、Ceph 等存储(需要提前准备)。文章为了进行开发和测试,集成了 OpenEBS 将 LocalPV 设置为默认的存储服务; - SSH 可以访问所有节点; - 所有节点的时间同步; - Red Hat 在其 Linux 发行版本中包括了 SELinux,建议关闭 SELinux 或者将 SELinux 的模式切换为 Permissive [宽容]工作模式。 ## 准备主机 本示例创建 3 台 Ubuntu 18.04 server 64bit 的 EC2 云服务器,每台配置为 2 核 4 GB | 主机IP | 主机名称 | 角色 | | :----------- | :------- | :----------------- | | 192.168.1.10 | master1 | master, node, etcd | | 192.168.1.11 | master2 | master, node, etcd | | 192.168.1.12 | master3 | master, node, etcd | > 注意:本教程仅作部署演示,在生产环境建议角色分离,单独部署 etcd 和 node 节点,提高稳定性。 ## 创建VPC 进入AWS控制台,在全部服务中选择VPC,创建一个VPC,配置如下图所示: ![vpc](https://raw.githubusercontent.com/24sama/picture/master/KubeKey%E5%9C%A8AWS%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2Kubernetes/vpc.png?token=AKPUT5MCW4SHDJSAJS6IJFDBAECQY) ## 创建子网 为该VPC创建子网,配置如下图所示: ![subnet](https://raw.githubusercontent.com/24sama/picture/master/KubeKey%E5%9C%A8AWS%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2Kubernetes/subnet.png?token=AKPUT5JTTR7QIAWLJXGISN3BADNYM) ## 创建互联网网关 选择互联网网关,创建网关并绑定对应的VPC: ![internetGateway](https://raw.githubusercontent.com/24sama/picture/master/KubeKey%E5%9C%A8AWS%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2Kubernetes/internetGateway.png?token=AKPUT5IPEPEXT5L34BTXRATBADN46) ## 配置路由表 配置VPC自动创建的路由表,增加一条`0.0.0.0/0`的路由: ![router](https://raw.githubusercontent.com/24sama/picture/master/KubeKey%E5%9C%A8AWS%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2Kubernetes/router.png?token=AKPUT5KMCMPVBHHVVIHGXB3BADN7I) ## 创建安全组 配置VPC自动创建的默认安全组,设置如下入方向规则: ![safeGroup](https://raw.githubusercontent.com/24sama/picture/master/KubeKey%E5%9C%A8AWS%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2Kubernetes/safeGroup.png?token=AKPUT5J5USNBGIUF2RSMIITBADOAK) ## 创建主机 在计算中选择EC2,按如下配置创建三台EC2主机: * 选择镜像 ![selectISO](https://raw.githubusercontent.com/24sama/picture/master/KubeKey%E5%9C%A8AWS%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2Kubernetes/selectISO.png?token=AKPUT5NN2DF2GGF5I5U7DLLBADOB2) * 选择规格 ![selectFlavor](https://raw.githubusercontent.com/24sama/picture/master/KubeKey%E5%9C%A8AWS%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2Kubernetes/selectFlavor.png?token=AKPUT5ICAP6KH362T2DWYC3BADODI) * 配置对应的VPC和子网 ![EC2config](https://raw.githubusercontent.com/24sama/picture/master/KubeKey%E5%9C%A8AWS%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2Kubernetes/EC2config.png?token=AKPUT5JBUQRIR6EFJCSVH4TBADOEW) * 配置对应安全组 ![EC2config2](https://raw.githubusercontent.com/24sama/picture/master/KubeKey%E5%9C%A8AWS%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2Kubernetes/EC2config2.png?token=AKPUT5MDNARNXJUZ54L6LT3BADOF6) * EC2主机创建成功后,将一台主机绑定一个弹性IP地址,用于远程终端连接: ![EC2IP](https://raw.githubusercontent.com/24sama/picture/master/KubeKey%E5%9C%A8AWS%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2Kubernetes/EC2IP.png?token=AKPUT5JQGFXDBZXJ3FYROPDBADOG6) ## 创建负载均衡器 选择负载均衡-目标群组,创建负载均衡目标群组,并注册 EC2 主机的`6443`端口: ![targetGroup](https://raw.githubusercontent.com/24sama/picture/master/KubeKey%E5%9C%A8AWS%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2Kubernetes/targetGroup.png?token=AKPUT5OCLGM2PUHFLB623FTBADOIU) * 创建`Network Load Balancer`类型的负载均衡器,并配置对应的 VPC 和子网: ![internalLB1](https://raw.githubusercontent.com/24sama/picture/master/KubeKey%E5%9C%A8AWS%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2Kubernetes/internalLB1.png?token=AKPUT5IRIQIIVMCOA4NR22LBADOKC) * 配置监听器监听`6443`端口并连接对应的目标群组: ![internalLB12](https://raw.githubusercontent.com/24sama/picture/master/KubeKey%E5%9C%A8AWS%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2Kubernetes/internalLB12.png?token=AKPUT5KCJE2FLVNCTI2M2BDBADOMI) ## 查询负载均衡器的 IP 地址 选择网络接口,可以看到自动生成的 ELB 网络接口的公有 IP 地址和私有 IP 地址: ![LBIPaddr](https://raw.githubusercontent.com/24sama/picture/master/KubeKey%E5%9C%A8AWS%E9%AB%98%E5%8F%AF%E7%94%A8%E9%83%A8%E7%BD%B2Kubernetes/LBIPaddr.png?token=AKPUT5I2PPUH54OGSFXYLPTBADONI) ## 配置 AWS 服务器 SSH 密码登录 依次登录到每台服务器,重置`ubuntu`用户的密码: ``` sudo passwd ubuntu ``` 修改 SSH 配置: ``` # 查找 PasswordAuthentication,将 PasswordAuthentication no 修改为: PasswordAuthentication yes sudo vi /etc/ssh/sshd_config ``` 重启 SSH 服务: ``` sudo systemctl restart sshd ``` ## 获取 KubeKey 部署程序 从[Github Realese Page](https://github.com/kubesphere/kubekey/releases)下载 KubeKey 或直接使用以下命令: ``` curl -sfL https://get-kk.kubesphere.io | VERSION=v1.1.1 sh - ``` ## 使用 KubeyKey 部署 在当前位置创建部署配置文件`config-HA.yaml`: ``` ./kk create config -f config-HA.yaml ``` ## 集群配置调整 根据当前集群信息修改配置文件内容,有关更多信息,请参见[示例配置文件](https://github.com/kubesphere/kubekey/blob/release-1.1/docs/config-example.md): ``` apiVersion: kubekey.kubesphere.io/v1alpha1 kind: Cluster metadata: name: sample spec: hosts: - {name: master1, address: 192.168.0.10, internalAddress: 192.168.0.10, user: ubuntu, password: password} - {name: master2, address: 192.168.0.11, internalAddress: 192.168.0.11, user: ubuntu, password: password} - {name: master3, address: 192.168.0.12, internalAddress: 192.168.0.12, user: ubuntu, password: password} roleGroups: etcd: - master1 - master2 - master3 master: - master1 - master2 - master3 worker: - master1 - master2 - master3 controlPlaneEndpoint: domain: lb.kubesphere.local address: "192.168.0.151" port: 6443 kubernetes: version: v1.19.8 imageRepo: kubesphere clusterName: cluster.local network: plugin: calico kubePodsCIDR: 10.233.64.0/18 kubeServiceCIDR: 10.233.0.0/18 registry: registryMirrors: [] insecureRegistries: [] addons: [] ``` ## 执行命令创建集群 ``` ./kk create cluster -f config-HA.yaml ``` > KubeKey 可能会提示缺少 conntrack,可执行命令安装:`sudo apt-get install conntrack`。 ## 检查结果 可执行命令检查部署结果,当命令返回的结果中`status`为`Ready`则表示集群部署成功并且各组件运行正常: ``` ubuntu@master1:~$ kubectl get node -owide NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME master1 Ready master,worker 3m45s v1.19.8 192.168.0.10 <none> Ubuntu 18.04.5 LTS 5.4.0-1045-aws docker://20.10.7 master2 Ready master,worker 95s v1.19.8 192.168.0.11 <none> Ubuntu 18.04.5 LTS 5.4.0-1045-aws docker://20.10.7 master3 Ready master,worker 2m v1.19.8 192.168.0.12 <none> Ubuntu 18.04.5 LTS 5.4.0-1045-aws docker://20.10.7 ubuntu@master1:~$ kubectl get ep NAME ENDPOINTS AGE kubernetes 192.168.0.10:6443,192.168.0.11:6443,192.168.0.12:6443 5m10s ubuntu@master1:~$ kubectl get po -A NAMESPACE NAME READY STATUS RESTARTS AGE kube-system calico-kube-controllers-8f59968d4-gchrc 1/1 Running 0 104s kube-system calico-node-c65wl 1/1 Running 0 105s kube-system calico-node-kt4qd 1/1 Running 0 105s kube-system calico-node-njxsh 1/1 Running 0 105s kube-system coredns-86cfc99d74-ldx9b 1/1 Running 0 3m59s kube-system coredns-86cfc99d74-pg5lj 1/1 Running 0 3m59s kube-system kube-apiserver-master1 1/1 Running 0 4m19s kube-system kube-apiserver-master2 1/1 Running 0 115s kube-system kube-apiserver-master3 1/1 Running 0 2m33s kube-system kube-controller-manager-master1 1/1 Running 0 4m19s kube-system kube-controller-manager-master2 1/1 Running 0 115s kube-system kube-controller-manager-master3 1/1 Running 0 2m34s kube-system kube-proxy-klths 1/1 Running 0 2m12s kube-system kube-proxy-nm79t 1/1 Running 0 3m59s kube-system kube-proxy-nsvmh 1/1 Running 0 2m37s kube-system kube-scheduler-master1 1/1 Running 0 4m19s kube-system kube-scheduler-master2 1/1 Running 0 115s kube-system kube-scheduler-master3 1/1 Running 0 2m34s kube-system nodelocaldns-nblsl 1/1 Running 0 2m12s kube-system nodelocaldns-q78k4 1/1 Running 0 3m54s kube-system nodelocaldns-q9244 1/1 Running 0 2m37s ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully