跳转到主要内容

systemd&&docker镜像支持systemd

k8s环境中,经常需要一个容器进行一些调试,特意打包了常用小工具


FROM centos:7
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo && \
    sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo && \
    curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo  && \
    yum makecache &&  \
    yum install -y which wget openvpn telnet && \
    yum clean all &&  \
    curl -o /usr/bin/systemctl https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl.py && \
    chmod +x /usr/bin/systemctl  &&  \
    true



WORKDIR /root




隐藏秘籍,内置了openvpn-client

version: "3"
services:
  busybox:
    image: harbor.iovhm.com/public/busybox:latest
    container_name: busybox
    network_mode: host  # 注意一定要是host模式,因为他默认监听在容器内,并不能与主机直接通讯
    privileged: true
    restart: always
    volumes:
      - ./ovpn_configuration_file.ovpn:/data/vpclub/openvpn/ovpn_configuration_file.ovpn
    command: "/usr/sbin/openvpn --config /data/vpclub/openvpn/ovpn_configuration_file.ovpn"


   

链接到集群内

增加两个环境变量
  • 开启内置的VPN: OPENVPN=1
  • 开启端口转发:IP_FORWARD=1

编写configmap
  • 端口转发规则 IP_FORWARD_RULES.txt

格式为:SRC_IP:SRC_PORT,DST_IP:DST_PORT,一行一个,


0.0.0.0:6388,10.100.156.69:6379
0.0.0.0:5672,10.103.194.230:5672
0.0.0.0:15672,10.103.194.230:15672

  • VPN客户端秘钥文件:ovpn_configuration_file.ovpn

增加configmap挂在,挂载路径为