我有一个使用nginx,php-fpm,mysql的示例项目: https://gitlab.com/x-team-blog/docker-compose-php
这是docker-compose文件:
subscribeNotification()
.subscribe(onSuccess: { info in
queryNotification()
.flatMap({ notification in
return getNotificationAttributes(uid: notification.uid, attributes: [.appIdentifier, .content])
})
.flatMap({ notifAttrs
return getAppAttributes(appIdentifier: notifAttrs.appIdentifier, attributes: [.displayName])
})
.subscribe {
// have all the result from last two calls
}
})
我想在Google Cloud中使用Kubernetes,为此,我创建了几个文件:
永久卷数据库-claim0-persistentvolumeclaim.yaml:
version: '3'
services:
php-fpm:
build:
context: ./php-fpm
volumes:
- ../src:/var/www
nginx:
build:
context: ./nginx
volumes:
- ../src:/var/www
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/sites/:/etc/nginx/sites-available
- ./nginx/conf.d/:/etc/nginx/conf.d
depends_on:
- php-fpm
ports:
- "80:80"
- "443:443"
database:
build:
context: ./database
environment:
- MYSQL_DATABASE=mydb
- MYSQL_USER=myuser
- MYSQL_PASSWORD=secret
- MYSQL_ROOT_PASSWORD=docker
volumes:
- ./database/data.sql:/docker-entrypoint-initdb.d/data.sql
我还创建了秘密:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: database-claim0
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 400Mi
然后我创建了一个服务:
kubectl create secret generic mysql --from-literal=MYSQL_DATABASE=mydb --from-literal=MYSQL_PASSWORD=secret --from-literal=MYSQL_ROOT_PASSWORD=docker --from-literal=MYSQL_USER=myuser
现在我想创建database-deployment.yaml,但是我不知道我在docker-compose之类的复制sql文件的volumeMounts部分中必须写什么:
apiVersion: v1
kind: Service
metadata:
name: database
labels:
app: database
spec:
type: ClusterIP
ports:
- port: 3306
selector:
app: database
database-deployment.yaml
- ./database/data.sql:/docker-entrypoint-initdb.d/data.sql
UPD: 我的错。我没有先推送图片。
答案 0 :(得分:2)
使用kompose
INFO Kubernetes file "nginx-service.yaml" created
INFO Kubernetes file "database-deployment.yaml" created
INFO Kubernetes file "database-claim0-persistentvolumeclaim.yaml" created
INFO Kubernetes file "nginx-deployment.yaml" created
INFO Kubernetes file "nginx-claim0-persistentvolumeclaim.yaml" created
INFO Kubernetes file "nginx-claim1-persistentvolumeclaim.yaml" created
INFO Kubernetes file "nginx-claim2-persistentvolumeclaim.yaml" created
INFO Kubernetes file "nginx-claim3-persistentvolumeclaim.yaml" created
INFO Kubernetes file "php-fpm-deployment.yaml" created
INFO Kubernetes file "php-fpm-claim0-persistentvolumeclaim.yaml" created
答案 1 :(得分:0)
这是一个在线工具here,可帮助生成转换为Kubernetes资源的大多数Docker组成文件