kubeadm部署高可用kubernetes集群

为了后便后期验证私有化部署 ,最近内网环境需要快速搭建一套k8s集群,由于之前对于规模比较大的集群,我一般采用kubeasz和kubespray来搞定,这次对于小环境集群,直接用kubeadm部署会更加高效。

阿里云PrivateZone+Bind9+Dnsmasq实现内部DNS

需求:

  • 阿里云集群能够解析内部域名
  • 办公网解析内部域名+办公网上网解析

解决方法:

  • 对于第一个问题,直接使用阿里云PrivateZone解析即可
  • 对于第二个问题,采用在PrivateZone配置内部域名zone,然后通过阿里云同步工具同步到办公网bind9服务器; 对于办公网DNS解析入口,使用Dnsmasq处理,对于公网解析直接Forward到公网DNS,内部域名直接转发到bind9处理。

这里可能有人疑问,为什么不用bind直接实现所有内部解析呢? 这里主要原因在实际使用中发现bind9的forward多个dns的时候并发有性能问题,偶尔会有超时现象,这一点dnsmasq做的相对出色很多。

Argo Events入门实践

前面我们介绍了Argo Workflow如何安装与触发任务,这一篇主要介绍一个新工具:

ArgoEvents是什么?

Argo Events是一个事件驱动的 Kubernetes 工作流自动化框架。它支持20 多种不同的事件(例如 webhook、S3 drop、cronjob、消息队列-例如 Kafka、GCP PubSub、SNS、 SQS等)

Argo Worflow实践一安装部署

简介&架构

Argo Workflows是一个开源容器级别工作流引擎,用于在Kubernetes上协调并行作业。 Argo Workflows通过抽象Kubernetes CRD(自定义资源定义)来实现整个架构功能,比如Workflow Template、Workflow、Cron Workflow。

Gitlab runner配置ceph s3

对于前端项目Npm构建的时候,经常拉取前端库耗时比较长,另外不同的job之间复用也是一个问题,无论是artifacts或者cache最终我们需要持久化复用文件,这里我们以cache为例

terraform自动化创建ECS

快速创建一台阿里云ECS主机

指定terraform版本

这里我们指定了阿里云provider版本信息,并设置了terraform的版本要求

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# mkdir aliyun-ecs-one && cd aliyun-ecs-one
# touch versions.tf
# vim versions.tf
 terraform {
  required_providers {
    alicloud = {
      source  = "aliyun/alicloud"
      version = "1.115.1"
    }
  }

  required_version = ">= 0.12"
}

配置变量

这里主要指定密钥对、云region、ECS账户和镜像信息

terraform安装与命令详解

安装Terraform

Mac系统安装

1
2
brew tap hashicorp/tap
brew install hashicorp/tap/terraform

Linux系统安装

  1. ubuntu安装
1
2
3
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install terraform
  1. centos系统
1
2
3
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo yum -y install terraform

验证安装

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# terraform -v
Terraform v0.14.3

Your version of Terraform is out of date! The latest version
is 0.14.7. You can update by downloading from https://www.terraform.io/downloads.html
# terraform
Usage: terraform [global options] <subcommand> [args]

The available commands for execution are listed below.
The primary workflow commands are given first, followed by
less common or more advanced commands.

Main commands:
  init          Prepare your working directory for other commands
  validate      Check whether the configuration is valid
  plan          Show changes required by the current configuration
  apply         Create or update infrastructure
  destroy       Destroy previously-created infrastructure

All other commands:
  console       Try Terraform expressions at an interactive command prompt
  fmt           Reformat your configuration in the standard style
  force-unlock  Release a stuck lock on the current workspace
  get           Install or upgrade remote Terraform modules
  graph         Generate a Graphviz graph of the steps in an operation
  import        Associate existing infrastructure with a Terraform resource
  login         Obtain and save credentials for a remote host
  logout        Remove locally-stored credentials for a remote host
  output        Show output values from your root module
  providers     Show the providers required for this configuration
  refresh       Update the state to match remote systems
  show          Show the current state or a saved plan
  state         Advanced state management
  taint         Mark a resource instance as not fully functional
  untaint       Remove the 'tainted' state from a resource instance
  version       Show the current Terraform version
  workspace     Workspace management

Global options (use these before the subcommand, if any):
  -chdir=DIR    Switch to a different working directory before executing the
                given subcommand.
  -help         Show this help output, or the help for a specified subcommand.
  -version      An alias for the "version" subcommand.

terraform命令之资源管理

资源初始化

对于一个terraform资源项目,我这里创建了3个基本文件,分别为:main.tf(入口文件),variables.tf(变量信息),versions.tf(版本信息)

自动化编排工具Terraform介绍

Terraform是什么?:

Terraform是由HashiCorp公司在2014年左右推出的开源资源编排工具, 目前几乎所有的主流云服务商都支持Terraform,包括阿里云、腾讯云、华为云、AWS、Azure、百度云等等。目前很多公司都基于terraform构建自己的基础架构。