<p>I am working on a project where I need to launch a particular deployment with a specific CIDR range. Is there any way i can do this ?</p>

<p>I need these CIDR ranges for different deployments.</p>

<p>For example:</p>

<ol>
<li><p>Deployment 1 - Have 10 replicas running with CIDR 10.10.10.0/24</p></li>
<li><p>Deployment 1 - Have 10 replicas running with CIDR 10.10.11.0/24</p></li>
</ol>

Udit Sarin
<p>This can be achieved by using Calico's IPPool. </p>

<ol>
<li><p>install kubernetes with calico.</p></li>
<li><p>you create a IPPool, copy the below Yaml content in a file. </p></li>
</ol>

<pre><code>apiVersion: projectcalico.org/v3
kind: IPPool
metadata:
  name: pool1
spec:
  cidr: 192.168.0.0/18
  ipipMode: Never
  natOutgoing: true
  disabled: false
  nodeSelector: all()
</code></pre>

<p>and apply this above yaml using the following command</p>

<pre><code>calicoctl create -f pool1.yaml
</code></pre>

<p>Now deploy any service like this </p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
      annotations:
        "cni.projectcalico.org/ipv4pools": "[\"192.168.0.0/18\"]"
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
</code></pre>

<p>Apply the above yaml using</p>

<pre><code>kubectl apply -f nginx.yaml
</code></pre>

<p>Check the ip of running pods using</p>

<pre><code>kubectl get pods -o wide
</code></pre>
