【阿里云系列】-ACK的应用服务如何暴露公网并挂载域名

背景介绍

针对部署到阿里云ACK集群的应用服务,实际业务场景可能需要我们暴露其中的服务到公网并要求通过域名访问改服务,那具体在阿里云平台上如何实现呢

配置步骤

新建ack集群是后续工作的第一前提由于篇幅有限就不在本文赘述,如下是基本准备工作:

1、将服务以NodePort方式部署在ACK中

如下图所示为部署的yaml文件

yaml 复制代码
apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-web
  namespace: prod  
  labels:
    app: test-web
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test-web
  template:
    metadata:
      labels:
        app: test-web
    spec:
      containers:
      - name: test-web
        image: registry-vpc.cn-shanghai.aliyuncs.com/prod-acr/test-web:${IMAGE-TAG}
        ports:
        - containerPort: 8080
#        resources:
#          limits:
#            cpu: "500m"
---
apiVersion: v1
kind: Service
metadata:
  name: test-web
  namespace: prod 
  labels:
    app: test-web
spec:
  selector:
    app: test-web
  ports:
  - name: http
    protocol: TCP
    port: 80
    targetPort: 8080
  - name: https
    protocol: TCP
    port: 443
    targetPort: 8080
  type: NodePort

2、配置AlbConfig

如下图所示,在工作负载-自定义资源中添加AlbConfig

yaml 复制代码
apiVersion: alibabacloud.com/v1
kind: AlbConfig
metadata:
  name: test-prod-alb
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: >
      {"apiVersion":"alibabacloud.com/v1","kind":"AlbConfig","metadata":{"annotations":{},"name":"test-prod-alb"},"spec":{"config":{"addressType":"Internet","id":"alb-dgggggggsaaayy7","name":"test-prod-alb","zoneMappings":[{"vSwitchId":"vsw-xxxxxyyyyyyyyg"},{"vSwitchId":"vsw-xxxxxxxyyyyhib"}]},"listeners":[{"port":80,"protocol":"HTTP"},{"port":443,"protocol":"HTTPS"}]}}
spec:
  config:
    addressType: Internet
    forceOverride: true
    id: alb-dgggggggsaaayy7
    listenerForceOverride: true
    name: test-prod-alb
    zoneMappings:
      - vSwitchId: vsw-xxxxxyyyyyyyyg
      - vSwitchId: vsw-xxxxxxxyyyyhib
  listeners:
    - port: 80
      protocol: HTTP
    - port: 443
      protocol: HTTPS

其中config.id代表是已有的ALB实例的ID,config.name则可以自定义,config.forceOverride为true则会强制替换已有的ALB实例的配置,zoneMappings.vSwitchId表示vpc网络的交换机的实例id

3、新建IngressClass

如下图所示,在工作负载-自定义资源中添加IngressClass

yaml 复制代码
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: alb
spec:
  controller: ingress.k8s.alibabacloud/alb
  parameters:
    apiGroup: alibabacloud.com
    kind: AlbConfig
    name: test-prod-alb
    scope: Cluster

4、配置证书密钥

如下图所示,在配置管理-保密字典中创建

点击创建按钮,如下图所示

其中TLS证书在后面的步骤中会提到如何新建SSL证书,在SSL证书平台中下载对应的证书,如下图所示

点击【下载】按钮,打开如下图所示页面:

下载之后获取证书和key文件,如下图所示

5.新建Ingress路由配置

在网络-路由中创建Ingress

点击【创建Ingress】如下图所示:

以上操作就会自动把SSL证书挂载到对应的ALB实例下

6、申请SSL证书

此步骤确定之后需要提交审核,免费证书通过审核要10几分钟,审核通过之后在SSL证书域名解析记录中会出现如下图所示的TXT类型的记录

7、添加域名解析

如下步骤则是将域名挂载到已有的ALB实例的动作

相关推荐
@HNUSTer1 小时前
基于 GEE 利用 WorldPop 数据集批量导出 100 米分辨率人口影像数据与时序分析
数据分析·云计算·数据集·遥感大数据·gee·云平台·worldpop
Lynnxiaowen3 小时前
今天我们开始学习Linux自动化运维Ansible基础
linux·运维·学习·自动化·云计算·ansible
云计算老刘4 小时前
1. Cockpit 管理服务器;2. Linux 软件包管理
linux·运维·服务器·云原生·云计算
郏国上5 小时前
由于图片视频替换和删除导致阿里云上存在大量系统不再使用的文件如何处理
数据库·mongodb·阿里云
专注VB编程开发20年5 小时前
阿里云域名DNS解析URL转发不支持HTTPS?
阿里云·域名·dns·ddns·url转发
Lucifer三思而后行5 小时前
使用 BR 备份 TiDB 到阿里云 OSS 存储
阿里云·云计算·tidb
wsad05325 小时前
Ubuntu 24.04 更换国内软件源(以阿里云为例)
linux·ubuntu·阿里云
周杰伦_Jay5 小时前
【多智能体协作】定义、机制、模式与实践全解析
人工智能·云计算
郏国上7 小时前
遍历访问阿里云节点下的所有文件信息并写入excel文件
数据库·mongodb·阿里云·excel
wanhengidc8 小时前
在云手机中云计算的作用都有哪些?
服务器·网络·游戏·智能手机·云计算