When I am giving hostpath it is showing that it is read-only file system since I am new to kubernetes I didn't find any other way please let me know such that is there any other way of implementation of volumes and I am doing this on GKE here is my yaml code
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "10"
creationTimestamp: "2019-11-22T10:52:16Z"
generation: 17
labels:
app: dataset
name: dataset
namespace: default
resourceVersion: "283767"
selfLink: /apis/apps/v1/namespaces/default/deployments/dataset
uid: 26111fe8-0d16-11ea-a66e-42010aa00042
spec:
progressDeadlineSeconds: 600
replicas: 2
revisionHistoryLimit: 10
selector:
matchLabels:
app: dataset
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: dataset
spec:
containers:
- env:
- name: RABBIT_MQ_HOST
valueFrom:
configMapKeyRef:
key: RABBIT_MQ_HOST
name: dataset-config
- name: RABBIT_MQ_USER
valueFrom:
configMapKeyRef:
key: RABBIT_MQ_USER
name: dataset-config
- name: RABBIT_MQ_PASSWORD
valueFrom:
configMapKeyRef:
key: RABBIT_MQ_PASSWORD
name: dataset-config
- name: DATASET_DB_HOST
valueFrom:
configMapKeyRef:
key: DATASET_DB_HOST
name: dataset-config
- name: DATASET_DB_NAME
valueFrom:
configMapKeyRef:
key: DATASET_DB_NAME
name: dataset-config
- name: LICENSE_SERVER
valueFrom:
configMapKeyRef:
key: LICENSE_SERVER
name: dataset-config
- name: DATASET_THUMBNAIL_SIZE
valueFrom:
configMapKeyRef:
key: DATASET_THUMBNAIL_SIZE
name: dataset-config
- name: GATEWAY_URL
valueFrom:
configMapKeyRef:
key: GATEWAY_URL
name: dataset-config
- name: DEFAULT_DATASOURCE_ID
valueFrom:
configMapKeyRef:
key: DEFAULT_DATASOURCE_ID
name: dataset-config
- name: RABBIT_MQ_QUEUE_NAME
valueFrom:
configMapKeyRef:
key: RABBIT_MQ_QUEUE_NAME
name: dataset-config
- name: RABBIT_MQ_PATTERN
valueFrom:
configMapKeyRef:
key: RABBIT_MQ_PATTERN
name: dataset-config
image: gcr.io/gcr-testing-258008/dataset@sha256:8416ec9b023d4a4587a511b855c2735b25a16dbb1a15531d8974d0ef89ad3d73
imagePullPolicy: IfNotPresent
name: dataset-sha256
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: ./data/uploads
name: dataset-volume-uploads
- mountPath: ./data/thumbnails
name: dataset-volume-thumbnails
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- hostPath:
path: /build/uploads
type: ""
name: dataset-volume-uploads
- hostPath:
path: /build/thumbnails
type: ""
name: dataset-volume-thumbnails
status:
availableReplicas: 2
conditions:
- lastTransitionTime: "2019-11-23T07:19:13Z"
lastUpdateTime: "2019-11-23T07:19:13Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: "True"
type: Available
- lastTransitionTime: "2019-11-23T06:31:03Z"
lastUpdateTime: "2019-11-23T07:24:42Z"
message: ReplicaSet "dataset-75b46f868f" is progressing.
reason: ReplicaSetUpdated
status: "True"
type: Progressing
observedGeneration: 17
readyReplicas: 2
replicas: 3
unavailableReplicas: 1
updatedReplicas: 1
Here is my description of pod
Path: /build/uploads
HostPathType:
dataset-volume-thumbnails:
Type: HostPath (bare host directory volume)
Path: /build/thumbnails
HostPathType:
default-token-x2wmw:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-x2wmw
Optional: false
QoS Class: Burstable
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
---- ------ ---- ---- -------
Normal Scheduled 96s default-scheduler Successfully assigned default/dataset-75b46f868f-wffm7 to gke-teric-ai-default-pool-41929025-fxnx
Warning BackOff 15s (x6 over 93s) kubelet, gke-teric-ai-default-pool-41929025-fxnx Back-off restarting failed container
Normal Pulled 2s (x5 over 95s) kubelet, gke-teric-ai-default-pool-41929025-fxnx Container image "gcr.io/gcr-testing-258008/dataset@sha256:8416ec9b023d4a4587a511b855c2735b25a16dbb1a15531d8974d0ef89ad3d73" already present on machine
Normal Created 2s (x5 over 95s) kubelet, gke-teric-ai-default-pool-41929025-fxnx Created container
Warning Failed 1s (x5 over 95s) kubelet, gke-teric-ai-default-pool-41929025-fxnx Error: failed to start container "dataset-sha256": Error response from daemon: error while creating mount source path '/build/uploads': mkdir /build/uploads: read-only file system
So here is the problem even though I am giving chmod permissions dynamically it is not allowing to do write operations.i have tried persistent volumes it is also not worked so please tell me know in which way I have to mount volumes.
I was able to create both hostPath on my GKE instance manually as root user.
I guess you have to specify type for hostPath to create request directory if it doesn't exist. type: DirectoryOrCreate
you can read more about hostPath and available type values. Moreover, if you are using hostPath permissions of your user inside a container must match ownership on the node so it makes it more complicated, of course, you could run it as root, but it is not recommended way.
To sum it up, just use persistent storage provisioned by google. If you encounter problems with permissions you probably need init contaner to change permission or you have to set proper fsGroup for your container.