首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >库伯内特斯不跑的狙击

库伯内特斯不跑的狙击
EN

Stack Overflow用户
提问于 2019-01-17 10:35:10
回答 1查看 846关注 0票数 2

我正在尝试在k8s集群上部署snipe it。

我在kubernetes上运行mysql

我想在kubernetes上部署狙击it应用程序。

我的yaml文件就像

代码语言:javascript
复制
apiVersion: v1
kind: Service
metadata:
  name: snipeit
  labels:
    app: snipeit
spec:
  ports:
    - port: 80
  selector:
    app: snipeit
    tier: frontend
  type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: snipeit-pv-claim
  labels:
    app: snipeit
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: snipeit
  labels:
    app: snipeit
spec:
  selector:
    matchLabels:
      app: snipeit
      tier: frontend
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: snipeit
        tier: frontend
    spec:
      containers:
      - image: snipe/snipe-it
        name: snipeit
        env:
        - name: DB_CONNECTION
          value: mysql
        - name: DB_HOST
          value: mysql
        - name: DB_USERNAME
          value: root
        - name: DB_DATABASE
          value: snipeit
        - name: APP_URL
          value: url
        - name: DB_PASSWORD
          value: password
        ports:
        - containerPort: 80
          name: snipeit
        volumeMounts:
        - name: snipeit-persistent-storage
          mountPath: /var/www/html
      volumes:
      - name: snipeit-persistent-storage
        persistentVolumeClaim:
          claimName: snipeit-pv-claim

这不管用

我使用的是来自码头枢纽的图像:

代码语言:javascript
复制
https://hub.docker.com/r/snipe/snipe-it

集线器狙击-it:https://github.com/snipe/snipe-it

容器开始运行,但我在容器中登录并检查var/www/html,但没有内容。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-18 10:31:01

代码语言:javascript
复制
apiVersion: v1
kind: ConfigMap
metadata:
  name: snipe-it-config
data:
  # Mysql Parameters
  MYSQL_PORT_3306_TCP_ADDR: "address"
  MYSQL_PORT_3306_TCP_PORT: "3306"
  MYSQL_DATABASE: "snipeit"
  MYSQL_USER: "user"
  MYSQL_PASSWORD: "pass"

  # Email Parameters
  # - the hostname/IP address of your mailserver
  MAIL_PORT_587_TCP_ADDR: "<smtp-host>"
  #the port for the mailserver (probably 587, could be another)
  MAIL_PORT_587_TCP_PORT: "587"
  # the default from address, and from name for emails
  MAIL_ENV_FROM_ADDR: "noreply@mydomain.com"
  MAIL_ENV_FROM_NAME: "Snipe-IT"
  # - pick 'tls' for SMTP-over-SSL, 'tcp' for unencrypted
  MAIL_ENV_ENCRYPTION: "tls"
  # SMTP username and password
  MAIL_ENV_USERNAME: "<smtp-username>"
  MAIL_ENV_PASSWORD: "<smtp-password>"

  # Snipe-IT Settings
  APP_ENV: "production"
  APP_DEBUG: "false"
  APP_KEY: "key"
  APP_URL: "http://127.0.0.1:80"
  APP_TIMEZONE: "Asia/Kolkata"
  APP_LOCALE: "en"
---
apiVersion: v1
kind: Service
metadata:
  name: snipeit
  labels:
    app: snipeit
spec:
  ports:
    - port: 80
  selector:
    app: snipeit
    tier: frontend
  type: LoadBalancer
---
apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: snipeit
  labels:
    app: snipeit
spec:
  selector:
    matchLabels:
      app: snipeit
      tier: frontend
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: snipeit
        tier: frontend
    spec:
      containers:
      - image: snipe/snipe-it
        name: snipeit
        envFrom:
            - configMapRef:
                name: snipe-it-config
        ports:
        - containerPort: 80
          name: snipeit
        volumeMounts:
        - name: snipeit-persistent-storage
          mountPath: /var/lib/snipeit
      volumes:
      - name: snipeit-persistent-storage
        persistentVolumeClaim:
          claimName: snipeit-pv-claim

我没有使用configmap,而是在部署中添加环境变量和参数,section...so只是添加了配置映射,并且运行顺利

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54233992

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档