Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to configure master slave in Azure K8s #100

Open
polganesh opened this issue Apr 5, 2019 · 1 comment
Open

Unable to configure master slave in Azure K8s #100

polganesh opened this issue Apr 5, 2019 · 1 comment

Comments

@polganesh
Copy link

Hi,
Following is my env
Cloud provider Azure
K8s Version 1.12.5

stateful set

apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: skeleton-mongodb
spec:
  serviceName: skeleton-mongodb
  replicas: 3
  selector:
    matchLabels:
      app: skeleton-mongodb
  template:
    metadata:
      labels:
        app: skeleton-mongodb
    spec:
      containers:
        - name: mongodb
          image: mongo:4
          resources:
            requests:
              memory: 250Mi
              cpu: 100m
            limits:
              memory: 500Mi
          ports:
            - containerPort: 27017
              name: mongo
          args:
            - "--bind_ip_all"
            - "--replSet"
            - rs0
          volumeMounts:
            - name: skeleton-mongodb-data
              mountPath: /data/db
            - name: skeleton-mongodb-init
              mountPath: /docker-entrypoint-initdb.d
          env:
            - name: MONGO_INITDB_ROOT_USERNAME
              valueFrom:
                configMapKeyRef:
                  name: skeleton
                  key: mongo_root-username
            - name: MONGO_INITDB_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: skeleton
                  key: mongodb_root-password
            - name: MONGO_INITDB_DATABASE
              valueFrom:
                configMapKeyRef:
                  name: skeleton
                  key: mongo_db
            - name: MONGO_USERNAME
              valueFrom:
                configMapKeyRef:
                  name: skeleton
                  key: mongo_username
            - name: MONGO_USER_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: skeleton
                  key: mongodb_user-password
        - name: mongo-sidecar
          image: cvallance/mongo-k8s-sidecar
          env:
            - name: MONGO_SIDECAR_POD_LABELS
              value: "app=skeleton-mongodb"
            - name: MONGODB_DATABASE
              valueFrom:
                configMapKeyRef:
                  name: skeleton
                  key: mongo_db
            - name: MONGODB_USERNAME
              valueFrom:
                configMapKeyRef:
                  name: skeleton
                  key: mongo_username
            - name: MONGODB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: skeleton
                  key: mongodb_user-password
      volumes:
      - name: skeleton-mongodb-init
        configMap:
          name: common-mongodb-init
  volumeClaimTemplates:
    - metadata:
        name: skeleton-mongodb-data
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 10Gi
        storageClassName: managed-premium

config map

apiVersion: v1
kind: ConfigMap
metadata:
  name: skeleton
data:
  mongo_port: "27017"
  mongo_host: skeleton-mongodb
  mongo_db: skeleton
  mongo_username: skeleton
  mongo_root-username: madmin
  

when i try to find which pod is my master i am unable to find any pod as a master.

for ((i = 0; i < 3; ++i)); 
do 
   kubectl exec --namespace default skeleton-mongodb-$i -- sh -c 'mongo --eval="printjson(rs.isMaster())"'; 
done

i found for all pods i am getting

{
"ismaster" : false,
"secondary" : false,
"info" : "Does not have a valid replica set config",

"isreplicaset" : true,
....
"readOnly" : false,
"ok" : 1
}

do i need to perform any specific steps to run it on azure aks cluster

@ravisjoshi
Copy link

@polganesh Did you find any solution for the same ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants