跳转至

阿里云容器服务ACK

一、配置专有网络

1.1进入阿里云VPC控制台

进入VPC控制台

1.2开通阿里云VPC服务

vpc控制台

vpc开通成功

1.3创建vpc

创建vpc

配置vpc01

配置vpc02

image-20221012160149721

二、配置Kubernetes集群

2.1进入阿里云ACK控制台

容器服务ack

进入ack控制台

2.2创建集群

2.2.1进入集群配置界面

创建集群

2.2.2选择集群配置

配置k8s01

配置k8s02

配置k8s03

2.2.3选择节点池配置

配置nodepool01

配置nodepool02

2.2.4选择组件配置

配置组件01

2.2.5确认配置

创建集群02

2.2.6创建集群

集群创建中

集群列表

三、阿里云控制台测试集群可用性

3.1创建Deployment

demo01

demo02

demo03

3.2创建Service

svcDemo01

svcDemo02

svcDemo03

3.3创建Ingress

ingressDemo01

ingressDemo02

访问01

3.4本地pc添加hosts(ingress域名未做备案)

同时按住win键+R键进入运行

修改hosts01

修改hosts02

修改hosts03

修改hosts04

3.5访问应用

访问02

四、通过api连接集群,并使用阿里云容器镜像仓库服务进行应用发布

4.1 安装kubectl

[root@kubemsb ~]# curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

[root@kubemsb ~]# chmod +x kubectl

[root@kubemsb ~]# install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

[root@kubemsb ~]# kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.2", GitCommit:"5835544ca568b757a8ecae5c153f317e5736700e", GitTreeState:"clean", BuildDate:"2022-09-21T14:33:49Z", GoVersion:"go1.19.1", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"24+", GitVersion:"v1.24.6-aliyun.1", GitCommit:"6965b276168c8f1e4a8545c52152838a2f433758", GitTreeState:"clean", BuildDate:"2022-09-22T08:06:05Z", GoVersion:"go1.18.6", Compiler:"gc", Platform:"linux/amd64"}

4.2 下载kubeConfig文件

连接k8s01

连接k8s02

[root@kubemsb ~]# mkdir /root/.kube
[root@kubemsb ~]# vim /root/.kube/config
apiVersion: v1
clusters:
- cluster:
    server: https://你的集群ip:6443
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURUakNDQWphZ0F3SUJBZ0lVWUJSR041Nm5lY3g4aDVLaVhCOUNnVFhUelJjd0RRWUpLb1pJaHZjTkFRRUwKQlFBd1BqRW5NQThHQTFVRUNoTUlhR0Z1WjNwb2IzVXdGQVlEVlFRS0V3MWhiR2xpWVdKaElHTnNiM1ZrTVJNdwpFUVlEVlFRREV3cHJkV0psY201bGRHVnpNQ0FYRFRJeU1UQXhNakEwTkRrd01Gb1lEekl3TlRJeE1EQTBNRFEwCk9UQXdXakErTVNjd0R3WURWUVFLRXdob1lXNW5lbWh2ZFRBVUJnTlZCQW9URFdGc2FXSmhZbUVnWTJ4dmRXUXgKRXpBUkJnTlZCQU1UQ210MVltVnlibVYwWlhNd2dnRWlNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0SUJEd0F3Z2dFSwpBb0lCQVFDbU82S0JQeFR2RGwwQnprdDI1K3hEMENwc3pSR0dpamllWnlWcnErUkxZd0JuN2duODNlRmtVYzJ3ClMzU091QWtjRCsvR3IrSExveTduZVVEbWJvVmZWUG82eEFDZ1A1dGgvVll4bU1GeVVIdytDQ3E1NmxPU1BGMysKQkJXMVRndnNzR25ZaTBhZXJXU211a05jS3lBMkRZTEVmRkw4R3FJRVZxWU1DTjNvcUJvUm5hZUEwSzViU2RFRApTV0JhN0ZtNmlXTlFwMldKUlhhS3Rad2thbzB0QU50NjU1ODBteTdPK3ZhV3E1b3owTXpPcS9jV211eFFvUnBGCmJhOUVSaU9qWFM0bDhsUzFGL010bjQ1bGFiZCtFMjh6R1h6alQzQytwU0FlWTdWLzZsd2tyN0RhdklMSkNSZ0EKMkpRdlZaV3ZRRTJQQWl6RXhMNDZKdHRzemtuYkFnTUJBQUdqUWpCQU1BNEdBMVVkRHdFQi93UUVBd0lDckRBUApCZ05WSFJNQkFmOEVCVEFEQVFIL01CMEdBMVVkRGdRV0JCUlhEL2hHbkFHd0hiZ0J5MXRHU1dGVENhY3NWREFOCkJna3Foa2lHOXcwQkFRc0ZBQU9DQVFFQWZOeFRTbnpwSWFhbVROazBvZW5iQ0pqRyszTCtQMklzTnFPMzdBZkwKVmVlbWdQOWlVYlgxazhqMzFOTDMxU3VOMVFNcmlJeXpBR3hENUgvYnJvQnREWFJ3cFd6S1BQcmw3cnlNNHZsRgp2TkZpZXhFUlB5L1VZNFRnZHVIRlNtY2JETnVpV2xFRVpyd00zMDV2U2VvOGI0WDFtWWpGWHM1aTBDY3ZwOWRmCnZibEFFcFZBV2x3NDZjM0R4UTc2RFFjR1RhUENWTjdPSXBONkRySnc5OE5jRzBkK1B2QnREclZxcGY0TGpuVHgKbEdyMkxBUGN5TVoyMzBuMngvS1h3KzZvc3M0RXo5R2FKajBDdTNhWWRmekgrOGszajZPQWNMVGMvaXJwN3R3RQovekJtMmhqUEpVT085Z0JSbzMwWUxDYnpBeDRiejRTZnlsUlJ6QVJzcCsxOGxRPT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: "kubernetes-admin"
  name: kubernetes-admin-c0aa8c47fbfab4b7ebf610d0214bfacd5
current-context: kubernetes-admin-c0aa8c47fbfab4b7ebf610d0214bfacd5
kind: Config
preferences: {}
users:
- name: "kubernetes-admin"
  user:
    client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQvRENDQXVTZ0F3SUJBZ0lEZUJIRE1BMEdDU3FHU0liM0RRRUJDd1VBTUdveEtqQW9CZ05WQkFvVElXTXcKWVdFNFl6UTNabUptWVdJMFlqZGxZbVkyTVRCa01ESXhOR0ptWVdOa05URVFNQTRHQTFVRUN4TUhaR1ZtWVhWcwp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xanBMZFc0T3U4RDBtemcwYWZmKzZla0NnWUFqSEsvSDQyNUIrVE9BSXpsb3VXa3kKY3hIb1dEQzh0dEQ0SHF5enpZZlE5NGRoNnZWT3JCV1dXbWhCUW5qNTJMVllFbzYrZzZTN1JabEhla2VSOHlITwprQmR2UnpXaVhlK2dYQUNNRVR2a2NpQ3diU1ZhT205WjRpRVBMa2J6cmNQUlNWTVRPcVllckk4Z2lPdCs0ekdBCnp6cjJwNWNNRHhCZ1IrQ08xQW5BcFFLQmdRQzVidEI3TXd3Y3F5WElMVlNONXNuMUN4cmgzZ2dNUG8zYUpVbzcKOGtBUUZkZXBrbDAwQTFkZnh0Uk14U2VhYlNrUmxNdUc0cm5ETmFtd3hnM0pTeVBEZEsza013NVNpdVpFVmpUSApzaGlxOE1JWDgrM0RTVldEMUgyUjRXcCtLdzhndXRjU3d2aWlUS1VxdFFVYWpON3dDUzlBZkcza0F4WW90ZW5xCkFKK1BJUUtCZ0MxRGFJdS9wWnVNa0FJTUpUZzdKUFZrVVlpMmZ6RkxqSTFQYS9qdWo4NGJ0TCtvRi9BdmZPblkKK1AvTjhHUWJ5UnNqc1owc2JzTzZvWUZrUVd4dlhWY1Y5a3NVNks5ZFpRUkNoSktrM0gxUzFvQ2xnclk2YkViKwowNFpKZlM0bWR0QzVvVVkydVNBdzEyOTI4MUpXdG9XdE5QaHRUeWlDV2xVclRNbDZQZ3R3Ci0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==

4.3 查看集群信息

[root@kubemsb ~]# kubectl get nodes --kubeconfig /root/.kube/config
NAME                       STATUS   ROLES    AGE     VERSION
cn-chengdu.192.168.10.43   Ready    <none>   3h37m   v1.24.6-aliyun.1
cn-chengdu.192.168.10.44   Ready    <none>   3h37m   v1.24.6-aliyun.1
cn-chengdu.192.168.10.45   Ready    <none>   3h37m   v1.24.6-aliyun.1

4.4 创建阿里云容器镜像服务

镜像服务

镜像服务02

镜像服务03

创建仓库01

创建仓库05

创建仓库03

创建仓库04

4.5 安装docker

[root@kubemsb ~]# wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@kubemsb ~]# yum -y install docker-ce
[root@kubemsb ~]# systemctl enable docker
[root@kubemsb ~]# systemctl start docker

4.6 上传镜像至服务器

将资源目录下的“apidemo.tar上传至服务器”

4.7 导入镜像

[root@kubemsb ~]# docker load -i apidemo.tar
[root@kubemsb ~]# docker images
REPOSITORY                                         TAG       IMAGE ID       CREATED         SIZE
apidemo                                            v1        cae07723a2c3   7 minutes ago   15.5MB

4.8 登录镜像仓库

[root@kubemsb ~]# docker login --username=你的用户名 registry.cn-chengdu.aliyuncs.com

4.9 上传镜像至阿里云镜像仓库

[root@kubemsb ~]# docker tag apidemo:v1 registry.cn-chengdu.aliyuncs.com/kubemsb/apidemo:v1
[root@kubemsb ~]# docker push registry.cn-chengdu.aliyuncs.com/kubemsb/apidemo:v1

image-20221012170435435

4.10在阿里云控制台部署项目

4.10.1 部署apidemo_Deployment

apidemo01

apidemo02

apidemo03

apidemo04

apidemo05

image-20221012170947145

image-20221012171112503

apidemo08

apidemo09

4.10.2 部署apidemo_SVC

apidemosvc01

apidemosvc02

4.10.3 部署apidemo_ingress

apidemoingress01

apidemoingress02

apidemoingress03

apidemoingress04

apidemoingress05

4.11 访问apidemo服务

4.11.1 pc添加hosts

修改hosts01

修改hosts02

修改hosts03

修改hosts05

4.11.2 访问apidemo服务

浏览器访问apidemo.kubemsb.com/info

返回如下信息则证明服务部署成功

image-20221012171836782