font / k8s-example-apps

Kubernetes reference applications
32 stars 40 forks source link

Error while creating deployment #9

Open rohits-splunk opened 1 year ago

rohits-splunk commented 1 year ago

kubectl create -f deployments/mongo-deployment.yaml

error: resource mapping not found for name: "mongo" namespace: "" from "deployments/mongo-deployment.yaml": no matches for kind "Deployment" in version "extensions/v1beta1" ensure CRDs are installed first

font commented 1 year ago

Thanks for reporting the issue! These manifests are a bit outdated as the Deployment API group has since been updated to apps/v1. If you try to replace extensions/v1beta1 with apps/v1 the error should be fixed.

rohits-splunk commented 1 year ago

I fixed it , thanks @font . Would you mind telling which mongo db version this app expects ? I installed the latest one and the app is complaining about.

font commented 1 year ago

I fixed it , thanks @font . Would you mind telling which mongo db version this app expects ? I installed the latest one and the app is complaining about.

Great question! The YAML manifests should really have specified the exact mongo version by tagging the image. At the time it wasn't an issue because any mongo version worked since it didn't rely on any unique mongo features. It was mongo 3.4 at the time.

In any case, make sure to align the MongoDB NodeJS driver version used in pacman with a MongoDB version that is compatible.

rohits-splunk commented 1 year ago

I am trying to install 3.4 but it wont install at all, because exact versions of other components are not know, then i tried 3.2 by following the link https://www.mongodb.com/docs/v3.2/tutorial/install-mongodb-on-ubuntu/ and it again failed due do dependencies.

Is there a possibility to upgrade the mongo used in the game along with the drivers ?

aespindola09 commented 1 year ago

To solve the version problem I ran the following commands to change the apiVersion and add the selector in the deployments

#Remplace apiVersion extensions/v1beta1 for apps/v1 for compatibility 
# Add selector name mongo
cat > deployments/mongo-deployment.yaml <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    name: mongo
  name: mongo
spec:
  replicas: 0
  selector:
    matchLabels:
      name: mongo
  template:
    metadata:
      labels:
        name: mongo
    spec:
      containers:
      - image: mongo
        name: mongo
        ports:
        - name: mongo
          containerPort: 27017
        volumeMounts:
          - name: mongo-db
            mountPath: /data/db
      volumes:
        - name: mongo-db
          persistentVolumeClaim:
            claimName: mongo-storage
EOF

#Remplace apiVersion extensions/v1beta1 for apps/v1 for compatibility
# Add selector name pacman
cat > deployments/pacman-deployment.yaml <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    name: pacman
  name: pacman
spec:
  replicas: 0
  selector:
    matchLabels:
      name: pacman
  template:
    metadata:
      labels:
        name: pacman
    spec:
      containers:
      - image: quay.io/ifont/pacman-nodejs-app:latest
        name: pacman
        ports:
        - containerPort: 8080
          name: http-server
EOF
rohits-splunk commented 1 year ago

Thanks , i was able to this as well. I am not sure if i am able to see any changes in the mongodb version !!