I follow this to install kong-ingress-controller in my master node. But when I deploy postgres-0 it created volume which is pending. I using my own cloud. Here is my yaml to create persistanvolume:
apiVersion: v1
kind: PersistentVolume
metadata:
name: postgre-pv-volume
namespace : kong
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/var/lib/postgresql/data"
When I run kubectl describe pod postgres-0 -n kong
Result:
Name: postgres-0
Namespace: kong
Priority: 0
Node: <none>
Labels: app=postgres
controller-revision-hash=postgres-59ccf8fcf7
statefulset.kubernetes.io/pod-name=postgres-0
Annotations: <none>
Status: Pending
IP:
IPs: <none>
Controlled By: StatefulSet/postgres
Containers:
postgres:
Image: postgres:9.5
Port: 5432/TCP
Host Port: 0/TCP
Environment:
POSTGRES_USER: kong
POSTGRES_PASSWORD: kong
POSTGRES_DB: kong
PGDATA: /var/lib/postgresql/data/pgdata
Mounts:
/var/lib/postgresql/data from datadir (rw,path="pgdata")
/var/run/secrets/kubernetes.io/serviceaccount from default-token-g7828 (ro)
Conditions:
Type Status
PodScheduled False
Volumes:
datadir:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: datadir-postgres-0
ReadOnly: false
default-token-g7828:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-g7828
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling <unknown> default-scheduler pod has unbound immediate PersistentVolumeClaims
Warning FailedScheduling <unknown> default-scheduler pod has unbound immediate PersistentVolumeClaims
Please help me. Thanks
Problem may lay in bad or none configuration of StorageClass.
1. Firstly you have to ensure that you have storageclass called manual.
$ kubectl get storageclass
The name of a StorageClass object is significant, and is how users can request a particular class.
2. To create StorageClass you have to define configuration file, here is example:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: manual
provisioner: xxx
reclaimPolicy: Retain
allowVolumeExpansion: true
mountOptions:
- debug
volumeBindingMode: Immediate
Storage classes have a provisioner that determines what volume plugin is used for provisioning PVs. This field must be specified (xxx).
Take note on such definition:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
Local volumes do not currently support dynamic provisioning, however a StorageClass should still be created to delay volume binding until pod scheduling. This is specified by the WaitForFirstConsumer volume binding mode.
Delaying volume binding allows the scheduler to consider all of a pod’s scheduling constraints when choosing an appropriate PersistentVolume for a PersistentVolumeClaim.
Let me know if it helps.