Add port mapping support for terway on ACK

简介: Add port mapping support for terway on Alibaba Cloud Container Service for Kubernetes (ACK).Work with terway, a CNI plugin for Alibaba Cloud VPC / Elastic Network Interface (ENI).

PortMap for Alibaba ACK

Add port mapping support for terway on Alibaba Cloud Container Service for Kubernetes (ACK).

Work with terway, a CNI plugin for Alibaba Cloud VPC / Elastic Network Interface (ENI).

Build Example

FROM alpine AS downloader

ARG TARGETOS=linux
ARG TARGETARCH
ARG VERSION=1.3.0

RUN apk add --no-cache wget

RUN wget https://github.com/containernetworking/plugins/releases/download/v${VERSION}/cni-plugins-${TARGETOS}-${TARGETARCH}-v${VERSION}.tgz \
         -O /cni-plugins.tgz && \
    tar -xzf /cni-plugins.tgz ./portmap -C /

FROM busybox

COPY --from=downloader /portmap /
docker buildx build \
       --tag registry.address.fix.me/portmap:v1.3.0 \
       --builder container \
       --platform linux/arm64,linux/amd64 \
       --progress plain \
       --push \
       .

Usage Example

Add a new ConfigMap for new init container.

kind: ConfigMap
apiVersion: v1
metadata:
  name: eni-config-cni
  namespace: kube-system
data:
  0-terway.conflist: |-
    {
   
        "cniVersion": "0.3.0",
        "name": "terway",
        "plugins": [
            {
   
                "type": "terway"
            },
            {
   
                "type": "portmap",
                "capabilities": {
   
                    "portMappings": true
                }
            }
        ]
    }

Add an init container to terway's deployment config yaml.

      initContainers:
# Add a new init container
        - name: terway-portmap-init
          command:
            - sh
            - '-c'
            - >-
              cp /portmap /opt/cni/bin/;
              chmod +x /opt/cni/bin/portmap;
              cp /etc/eni/0-terway.conflist /etc/cni/net.d/
          image: 'registry.address.fix.me/portmap:v1.3.0'
          securityContext:
            privileged: true
            procMount: Default
          volumeMounts:
            - name: cni-bin
              mountPath: /opt/cni/bin/
            - name: configvolume-cni
              mountPath: /etc/eni
            - name: cni
              mountPath: /etc/cni/net.d/
# DO NOT modify the original volumes config, just add new elements for new configMap.
# Digital pre set in default file name is 10-terway.conf, and new file name is 0-terway.conflist
# 0 < 10, this makes sure the file 0-terway.conflist will be load.
      volumes:
        - name: configvolume-cni
          configMap:
            name: eni-config-cni
            items:
              - key: 0-terway.conflist
                path: 0-terway.conflist
            defaultMode: 420

Trouble Shooting

Find out port mapping status.

iptables -t nat -vnL | grep CNI

Delete the CNI hostport related iptables Rules, Chains, and then recreate the pod that use the hostPort.

iptables -t nat -D xxxx n
iptables -t nat -X xxxx

Originally published address: https://github.com/maskshell/ack-portmap

相关实践学习
深入解析Docker容器化技术
Docker是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的Linux机器上,也可以实现虚拟化,容器是完全使用沙箱机制,相互之间不会有任何接口。Docker是世界领先的软件容器平台。开发人员利用Docker可以消除协作编码时“在我的机器上可正常工作”的问题。运维人员利用Docker可以在隔离容器中并行运行和管理应用,获得更好的计算密度。企业利用Docker可以构建敏捷的软件交付管道,以更快的速度、更高的安全性和可靠的信誉为Linux和Windows Server应用发布新功能。 在本套课程中,我们将全面的讲解Docker技术栈,从环境安装到容器、镜像操作以及生产环境如何部署开发的微服务应用。本课程由黑马程序员提供。 &nbsp; &nbsp; 相关的阿里云产品:容器服务 ACK 容器服务 Kubernetes 版(简称 ACK)提供高性能可伸缩的容器应用管理能力,支持企业级容器化应用的全生命周期管理。整合阿里云虚拟化、存储、网络和安全能力,打造云端最佳容器化应用运行环境。 了解产品详情: https://www.aliyun.com/product/kubernetes
相关文章
|
Kubernetes 网络协议 容器
Kubernetes - 内部 IP/DNS/Port 寻址匹配讲解
Kubernetes - 内部 IP/DNS/Port 寻址匹配讲解
581 0
Kubernetes - 内部 IP/DNS/Port 寻址匹配讲解
|
Kubernetes 容器 Perl
Kubernetes - Port,Targetport 和 NodePort的关系
这是 Kubernetes 的ipTables 配置的结果。它维护 nodePort 与 targetPort 的映射。K8s Kube-Proxy使用ipTables来解析特定nodePort上的请求,并将它们重定向到适当的pod。
988 0
|
Kubernetes 容器 Perl
kubernetes中port、target port、node port的对比分析,以及kube-proxy代理
容器网络实例 服务中的3个端口设置 这几个port的概念很容易混淆,比如创建如下service: [plain] view plain copy apiVersion: v1 kind: Service metadata: labels: name: app1 name: app.
2294 0
|
Android开发 网络协议
android搭建环境错误 daemon not running. starting it now on port 5037 ADB server didn&#39;t ACK
android搭建环境错误  daemon not running. starting it now on port 5037 ADB server didn't ACK ADB server didnt ACKdaemon not running.
2588 0
|
9月前
|
人工智能 算法 调度
阿里云ACK托管集群Pro版共享GPU调度操作指南
本文介绍在阿里云ACK托管集群Pro版中,如何通过共享GPU调度实现显存与算力的精细化分配,涵盖前提条件、使用限制、节点池配置及任务部署全流程,提升GPU资源利用率,适用于AI训练与推理场景。
718 1
|
9月前
|
弹性计算 监控 调度
ACK One 注册集群云端节点池升级:IDC 集群一键接入云端 GPU 算力,接入效率提升 80%
ACK One注册集群节点池实现“一键接入”,免去手动编写脚本与GPU驱动安装,支持自动扩缩容与多场景调度,大幅提升K8s集群管理效率。
516 89
|
资源调度 Kubernetes 调度
从单集群到多集群的快速无损转型:ACK One 多集群应用分发
本文介绍如何利用阿里云的分布式云容器平台ACK One的多集群应用分发功能,结合云效CD能力,快速将单集群CD系统升级为多集群CD系统。通过增加分发策略(PropagationPolicy)和差异化策略(OverridePolicy),并修改单集群kubeconfig为舰队kubeconfig,可实现无损改造。该方案具备多地域多集群智能资源调度、重调度及故障迁移等能力,帮助用户提升业务效率与可靠性。
|
资源调度 Kubernetes 调度
从单集群到多集群的快速无损转型:ACK One 多集群应用分发
ACK One 的多集群应用分发,可以最小成本地结合您已有的单集群 CD 系统,无需对原先应用资源 YAML 进行修改,即可快速构建成多集群的 CD 系统,并同时获得强大的多集群资源调度和分发的能力。
1078 9
|
存储 Kubernetes 监控
K8s集群实战:使用kubeadm和kuboard部署Kubernetes集群
总之,使用kubeadm和kuboard部署K8s集群就像回归童年一样,简单又有趣。不要忘记,技术是为人服务的,用K8s集群操控云端资源,我们不过是想在复杂的世界找寻简单。尽管部署过程可能遇到困难,但朝着简化复杂的目标,我们就能找到意义和乐趣。希望你也能利用这些工具,找到你的乐趣,满足你的需求。
1280 33
|
Prometheus Kubernetes 监控
OpenAI故障复盘 - 阿里云容器服务与可观测产品如何保障大规模K8s集群稳定性
聚焦近日OpenAI的大规模K8s集群故障,介绍阿里云容器服务与可观测团队在大规模K8s场景下我们的建设与沉淀。以及分享对类似故障问题的应对方案:包括在K8s和Prometheus的高可用架构设计方面、事前事后的稳定性保障体系方面。