简体   繁体   中英

Migrate docker-compose to Kubernetes

I'm trying to deploy free5GC ( cluster version ) over K8s. The problem with this software is that there are some services that have to know other service IPs before starting. I solve this issue in docker-compose executing a script inside each docker container with other service IPs as parameters. This is my docker-compose.yaml:

version: '3'

networks:
    testing_net:
        ipam:
            driver: default
            config:
                - subnet: 172.28.0.0/16

services:
  mongo:
    container_name: mongo
    image: mongo
    networks: 
      testing_net:
        ipv4_address: ${mongo_ip}

  webui:
    container_name: webui
    image: j0lama/free5gc-webui
    depends_on:
      - mongo
    ports:
      - '80:3000'
    extra_hosts:
      - "mongo:${mongo_ip}"
    networks: 
      testing_net:
        ipv4_address: ${webui_ip}

  hss:
    container_name: hss
    command: bash -c "./hss_setup.sh ${mongo_ip} ${hss_ip} ${amf_ip}"
    image: j0lama/free5gc-hss
    depends_on:
      - mongo
    networks: 
      testing_net:
        ipv4_address: ${hss_ip}

  amf:
    container_name: amf
    command: bash -c "./amf_setup.sh ${mongo_ip} ${hss_ip} ${amf_ip} ${smf_ip}"
    image: j0lama/free5gc-amf
    depends_on:
      - mongo
      - hss
    ports:
      - '36412:36412'
    networks: 
      testing_net:
        ipv4_address: ${amf_ip}

  smf:
    container_name: smf
    command: bash -c "./smf_setup.sh ${smf_ip} ${upf_ip} ${pcrf_ip}"
    image: j0lama/free5gc-smf
    depends_on:
      - mongo
      - hss
      - amf
    networks: 
      testing_net:
        ipv4_address: ${smf_ip}

  pcrf:
    container_name: pcrf
    command: bash -c "./pcrf_setup.sh ${mongo_ip} ${smf_ip} ${pcrf_ip}"
    image: j0lama/free5gc-pcrf
    depends_on:
      - mongo
      - hss
      - amf
      - smf
    networks: 
      testing_net:
        ipv4_address: ${pcrf_ip}

  upf:
    container_name: upf
    command: bash -c "./upf_setup.sh ${upf_ip}"
    image: j0lama/free5gc-upf
    depends_on:
      - mongo
      - hss
      - amf
      - smf
      - pcrf
    networks: 
      testing_net:
        ipv4_address: ${upf_ip}

With this I am able to setup all the components of my cluster correctly. I already try kompose utility but does not work.

Any suggestion or alternative for kubernetes?

Thanks for your help.

You can expose each deployment with a kubernetes service. When you do that, each exposed service cluster IP will be available to the containers as environment variables.

For example: deploy hss, and expose hss ports using a service named hss . Then, any container that needs to connect to hss can use the environment variable HSS_SERVICE_HOST to get the IP address for that service. There are more environment variable that will give you service port numbers, or service addresses in other formats.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM