https://pulumi.com logo
#kubernetes
Title
# kubernetes
f

famous-bear-66383

07/09/2020, 1:19 PM
I’d like to use pulumi to deploy similar Statefulset,
Copy code
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mysql
  labels:
    app: platform
spec:
  serviceName: mysql
  replicas: 1
  selector:
      matchLabels:
        app: platform
  template:
    metadata:
      labels:
        app: platform
        tier: mysql
      annotations:
        <http://sidecar.istio.io/inject|sidecar.istio.io/inject>: "false"
    spec:
      terminationGracePeriodSeconds: 30
      containers:
      - image: mysql:5
        name: mysql
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-pass
              key: mysql-password.txt
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: mysql-pv-claim
I come to this representation so far:
Copy code
const mysqlPVC = new kx.PersistentVolumeClaim("mysql-pvc", {
    metadata: {
        name: "mysql-pv-claim",
        namespace: ns,
        labels: {
            app: "platform"
        }
    },
    spec: {
        accessModes: ["ReadWriteOnce"],
        resources: {
            requests: {
                storage: "5Gi"
            }
        }
    }
});
const pb = new kx.PodBuilder({
    terminationGracePeriodSeconds: 30,
    containers: [{
        name: "mysql",
        image: "mysql:5.7",
        ports: {mysql: 3306},
        // The PodBuilder automatically creates the corresponding volume and naming boilerplate.
        volumeMounts: [mysqlPVC.mount("/var/lib/mysql")]
    }]
});

const mysqlpd = new kx.StatefulSet("mysql", {
    metadata: {
        name: "mysql",
        namespace: ns,
        labels: {
            app: "platform-database" 
        },
    },
    spec: pb.asStatefulSetSpec({replicas: 1})
});
My problem is how can I add annotation to the container spec. As you can see above there’s the following annotation `sidecar.istio.io/inject: "false"`which forbids istio from injecting a side car. How can I add it using PodBuilder ?
g

gorgeous-egg-16927

07/09/2020, 4:25 PM
It’s not currently possible with kx. See https://github.com/pulumi/pulumi-kubernetesx/issues/50
4 Views