Kubernetes PersistentVolumeClaim issues in AWS-using volumeClaimTemplates

1/26/2018

We have success creating the pods, services and replication controllers according to our project requirements. Now we are planning to setup persistence storage in AWS using Kubernetes. I have created the YAML file to create an EBS volume in AWS, it's working fine as expected. I am able to claim volume and successfully mount to my pod (this is for single replica only).

My file storage:

kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
  name: mongo-ssd
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2

Main file:

apiVersion: v1
kind: ReplicationController
metadata:
  labels:
    name: mongo-pp
  name: mongo-controller-pp
spec:
  replicas: 2
  template:
    metadata:
      labels:
        name: mongo-pp
    spec:
      containers:
      - image: mongo
        name: mongo-pp
        ports:
        - name: mongo-pp
          containerPort: 27017
          hostPort: 27017
        volumeMounts:
        - name: mongo-data
          mountPath: "/opt/couchbase/var"
  volumeClaimTemplates:
  - metadata:
      name: mongo-data
      annotations:
        volume.alpha.kubernetes.io/storage-class: mongo-ssd
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 1Gi

Storage is successfully creating. Whenever I am trying to run the main file I am facing the error like:

error: unable to recognize ".": no matches for apps/, Kind=ReplicationController

Can someone please assist me how to resolve this issue?

-- Raju
kubernetes

0 Answers