Skip to content

Create Pods in specific Subnet

Huanyu He edited this page Mar 21, 2022 · 7 revisions

Annotating pods with "networking.alibaba.com/specified-subnet" makes them be created in a specified Subnet.

For example:

---
apiVersion: networking.alibaba.com/v1
kind: Subnet
metadata:
  name: subnet1
spec:
  network: network1
  netID: 0
  range:
    version: "4"
    cidr: "192.168.56.0/24"
    gateway: "192.168.56.1"
  config:
    macNatEnable: true 
    private: true 

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: curl-deployment
spec:
  selector:
    matchLabels:
      app: curl
  replicas: 6
  template:
    metadata:
      annotations:
        networking.alibaba.com/specified-subnet: subnet1 
      labels:
        app: curl
    spec:
      containers:
      - args:
        - -c
        - sleep 999999999
        command:
        - /bin/sh
        name: curl
        image: tutum/curl:alpine