美文网首页
k8s initContainers demo pod依赖

k8s initContainers demo pod依赖

作者: shangyaqi | 来源:发表于2018-11-15 11:01 被阅读32次

    apiVersion: v1
    kind: Service
    metadata:
    name: mysql
    spec:
    clusterIP: None
    ports:

    • name: mysql
      port: 3306
      selector:
      app: mysql

    apiVersion: v1
    kind: Service
    metadata:
    name: wordpress
    spec:
    ports:

    • name: wordpress
      port: 80
      targetPort: 80
      selector:
      app: wordpress
      type: NodePort

    apiVersion: apps/v1
    kind: StatefulSet
    metadata:
    name: mysql
    spec:
    selector:
    matchLabels:
    app: mysql
    serviceName: mysql
    replicas: 1
    template:
    metadata:
    labels:
    app: mysql
    spec:
    containers:
    - name: mysql
    image: mysql:5.7
    env:
    - name: MYSQL_ALLOW_EMPTY_PASSWORD
    value: "true"
    livenessProbe:
    exec:
    command: ["mysqladmin", "ping"]
    initialDelaySeconds: 30
    periodSeconds: 10
    timeoutSeconds: 5
    readinessProbe:
    exec:
    # Check we can execute queries over TCP (skip-networking is off).
    command: ["mysql", "-h", "127.0.0.1", "-e", "SELECT 1"]
    initialDelaySeconds: 5
    periodSeconds: 2
    timeoutSeconds: 1


    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: wordpress
    spec:
    replicas: 1
    selector:
    matchLabels:
    app: wordpress
    template:
    metadata:
    labels:
    app: wordpress
    spec:
    containers:
    - name: wordpress
    image: wordpress:4
    ports:
    - containerPort: 80
    env:
    - name: WORDPRESS_DB_HOST
    value: mysql
    - name: WORDPRESS_DB_PASSWORD
    value: ""
    initContainers:
    - name: init-mysql
    image: busybox
    command: ['sh', '-c', 'until nslookup mysql; do echo waiting for mysql; sleep 2; done;']

    相关文章

      网友评论

          本文标题:k8s initContainers demo pod依赖

          本文链接:https://www.haomeiwen.com/subject/qsnefqtx.html