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 get sidecar initialize my mongo-pod #128

Open
jmndao opened this issue Dec 13, 2022 · 0 comments
Open

unable to get sidecar initialize my mongo-pod #128

jmndao opened this issue Dec 13, 2022 · 0 comments

Comments

@jmndao
Copy link

jmndao commented Dec 13, 2022

I'm trying to have a statefulset mongo pod but after I apply my current configuration and then check for master I don't see anything. I need to call initialize manually.

Current configuration:

# # Auth Service
apiVersion: v1
kind: Service
metadata:
  name: auth-mongo-srv
spec:
  selector:
    app: auth-mongo
  ports:
    - name: auth-db
      protocol: TCP
      port: 27017
      targetPort: 27017
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: auth-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: auth-pv
spec:
  capacity:
    storage: 1Gi
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Delete
  storageClassName: local-storage
  local:
    path: /data/auth-db
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - minikube
---
# # RBAC for Auth
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: default-view
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: view
subjects:
  - kind: ServiceAccount
    name: default
    namespace: default
---
# # Stateful Config
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: auth-mongo
spec:
  selector:
    matchLabels:
      app: auth-mongo
  serviceName: auth-mongo-srv
  replicas: 3 
  template:
    metadata:
      labels:
        app: auth-mongo
        environment: development
    spec:
      terminationGracePeriodSeconds: 10
      containers:
        - name: auth-mongo
          image: mongo
          command:
            - mongod
            - "--bind_ip_all"
            - "--replSet"
            - rs0
          ports:
            - containerPort: 27017
              name: auth-db
          volumeMounts:
            - name: auth-pv
              mountPath: /data/auth-db
        - name: auth-mongo-sidecar
          image: cvallance/mongo-k8s-sidecar
          env:
            - name: MONGO_SIDECAR_POD_LABELS
              value: "app=auth-mongo"
            - name: KUBERNETES_MONGO_SERVICE_NAME
              value: "auth-mongo-srv"
      volumes:
        - name: auth-pv
          persistentVolumeClaim:
            claimName: auth-pv
  volumeClaimTemplates:
    - metadata:
        name: auth-pv
      spec:
        accessModes: ["ReadWriteOnce"]
        resources:
          requests:
            storage: 1Gi

When I run kubectl exec -ti auth-mongo-0 -- mongosh

Defaulted container "auth-mongo" out of: auth-mongo, auth-mongo-sidecar
Current Mongosh Log ID:	6397c0522be19845836930ec
Connecting to:		mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.6.1
Using MongoDB:		6.0.3
Using Mongosh:		1.6.1

For mongosh info see: https://docs.mongodb.com/mongodb-shell/


To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.

------
   The server generated these startup warnings when booting
   2022-12-12T23:53:31.012+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
   2022-12-12T23:53:31.149+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
   2022-12-12T23:53:31.149+00:00: You are running this process as the root user, which is not recommended
   2022-12-12T23:53:31.149+00:00: vm.max_map_count is too low
------

------
   Enable MongoDB's free cloud-based monitoring service, which will then receive and display
   metrics about your deployment (disk utilization, CPU, operation statistics, etc).
   
   The monitoring data will be available on a MongoDB website with a unique URL accessible to you
   and anyone you share the URL with. MongoDB may use this information to make product
   improvements and to suggest MongoDB products and deployment options to you.
   
   To enable free monitoring, run the following command: db.enableFreeMonitoring()
   To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
------

test> 

I don't know what's going on and where did I miss the point

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

1 participant