feat: support container volume mount subpath (#1628)

* feat: support volumes subpath

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>

* docs: add the kompose.volume.sub-path label

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>

* fix: update e2e tests

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>

---------

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
This commit is contained in:
AhmedGrati
2023-07-05 10:47:01 +01:00
committed by GitHub
parent d1e32e7d7d
commit 485cd2f163
10 changed files with 267 additions and 2 deletions
+15
View File
@@ -0,0 +1,15 @@
version: '3.8'
volumes:
postgres-data:
services:
postgres:
labels:
kompose.volume.subpath: test
image: postgres
environment:
POSTGRES_USER: dumb_postgres_user
POSTGRES_PASSWORD: postgres_password
POSTGRES_DB: dumb_db
volumes:
- postgres-data:/var/lib/postgresql/data
+80
View File
@@ -0,0 +1,80 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.volume.subpath: test
creationTimestamp: null
labels:
io.kompose.service: postgres
name: postgres
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: postgres
strategy:
type: Recreate
template:
metadata:
annotations:
kompose.volume.subpath: test
creationTimestamp: null
labels:
io.kompose.network/vols-subpath-default: "true"
io.kompose.service: postgres
spec:
containers:
- env:
- name: POSTGRES_DB
value: dumb_db
- name: POSTGRES_PASSWORD
value: postgres_password
- name: POSTGRES_USER
value: dumb_postgres_user
image: postgres
name: postgres
resources: {}
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgres-data
subPath: test
restartPolicy: Always
volumes:
- name: postgres-data
persistentVolumeClaim:
claimName: postgres-data
status: {}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: postgres-data
name: postgres-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
creationTimestamp: null
name: vols-subpath-default
spec:
ingress:
- from:
- podSelector:
matchLabels:
io.kompose.network/vols-subpath-default: "true"
podSelector:
matchLabels:
io.kompose.network/vols-subpath-default: "true"
+103
View File
@@ -0,0 +1,103 @@
---
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
annotations:
kompose.volume.subpath: test
creationTimestamp: null
labels:
io.kompose.service: postgres
name: postgres
spec:
replicas: 1
selector:
io.kompose.service: postgres
strategy:
resources: {}
type: Recreate
template:
metadata:
creationTimestamp: null
labels:
io.kompose.network/vols-subpath-default: "true"
io.kompose.service: postgres
spec:
containers:
- env:
- name: POSTGRES_DB
value: dumb_db
- name: POSTGRES_PASSWORD
value: postgres_password
- name: POSTGRES_USER
value: dumb_postgres_user
image: ' '
name: postgres
resources: {}
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgres-data
subPath: test
restartPolicy: Always
volumes:
- name: postgres-data
persistentVolumeClaim:
claimName: postgres-data
test: false
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- postgres
from:
kind: ImageStreamTag
name: postgres:latest
type: ImageChange
status:
availableReplicas: 0
latestVersion: 0
observedGeneration: 0
replicas: 0
unavailableReplicas: 0
updatedReplicas: 0
---
apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
creationTimestamp: null
labels:
io.kompose.service: postgres
name: postgres
spec:
lookupPolicy:
local: false
tags:
- annotations: null
from:
kind: DockerImage
name: postgres
generation: null
importPolicy: {}
name: latest
referencePolicy:
type: ""
status:
dockerImageRepository: ""
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: postgres-data
name: postgres-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}