Kubernetes 中容器的命令行参数

Command Line Arguments for Container in Kubernetes

我正在尝试将 docker 容器部署到我的 Kubernetes 集群,但我 运行 遇到了将所需命令行参数传递给容器的问题。我需要传递两个参数 --provider local--basedir /tmp。这是 docker 运行 命令的样子(我可以 运行 在我的 docker 主机上没有任何问题):

docker run -d -p 8080:8080 --name transfer-sh -v /tmp:/tmp dutchcoders/transfer.sh:latest --provider local --basedir /tmp

但是,当我将部署 YAML 应用到我的集群时,容器失败并出现此错误(我正在 运行宁 kubectl apply -f deploy.yaml 将我的更改应用到集群):

Incorrect Usage. flag provided but not defined: -provider local

所以我的 YAML 指定标志应该是 --provider,但由于某种原因我还没有找到容器只看到 -provider 这确实不是一个有效的选项。这是完整的帮助信息:

NAME:
transfer.sh - transfer.sh

DESCRIPTION:
Easy file sharing from the command line

USAGE:
transfer.sh [flags] command [arguments...]

COMMANDS:
version
help, h  Shows a list of commands or help for one command

FLAGS:
--listener value                     127.0.0.1:8080 (default: "127.0.0.1:8080") [$LISTENER]
--profile-listener value             127.0.0.1:6060 [$PROFILE_LISTENER]
--force-https                         [$FORCE_HTTPS]
--tls-listener value                 127.0.0.1:8443 [$TLS_LISTENER]
--tls-listener-only                   [$TLS_LISTENER_ONLY]
--tls-cert-file value                 [$TLS_CERT_FILE]
--tls-private-key value               [$TLS_PRIVATE_KEY]
--temp-path value                    path to temp files (default: "/tmp") [$TEMP_PATH]
--web-path value                     path to static web files [$WEB_PATH]
--proxy-path value                   path prefix when service is run behind a proxy [$PROXY_PATH]
--proxy-port value                   port of the proxy when the service is run behind a proxy [$PROXY_PORT]
--email-contact value                email address to link in Contact Us (front end) [$EMAIL_CONTACT]
--ga-key value                       key for google analytics (front end) [$GA_KEY]
--uservoice-key value                key for user voice (front end) [$USERVOICE_KEY]
--provider value                     s3|gdrive|local [$PROVIDER]
--s3-endpoint value                   [$S3_ENDPOINT]
--s3-region value                    (default: "eu-west-1") [$S3_REGION]
--aws-access-key value                [$AWS_ACCESS_KEY]
--aws-secret-key value                [$AWS_SECRET_KEY]
--bucket value                        [$BUCKET]
--s3-no-multipart                    Disables S3 Multipart Puts [$S3_NO_MULTIPART]
--s3-path-style                      Forces path style URLs, required for Minio. [$S3_PATH_STYLE]
--gdrive-client-json-filepath value   [$GDRIVE_CLIENT_JSON_FILEPATH]
--gdrive-local-config-path value      [$GDRIVE_LOCAL_CONFIG_PATH]
--gdrive-chunk-size value            (default: 16) [$GDRIVE_CHUNK_SIZE]
--storj-access value                 Access for the project [$STORJ_ACCESS]
--storj-bucket value                 Bucket to use within the project [$STORJ_BUCKET]
--rate-limit value                   requests per minute (default: 0) [$RATE_LIMIT]
--purge-days value                   number of days after uploads are purged automatically (default: 0) [$PURGE_DAYS]
--purge-interval value               interval in hours to run the automatic purge for (default: 0) [$PURGE_INTERVAL]
--max-upload-size value              max limit for upload, in kilobytes (default: 0) [$MAX_UPLOAD_SIZE]
--lets-encrypt-hosts value           host1, host2 [$HOSTS]
--log value                          /var/log/transfersh.log [$LOG]
--basedir value                      path to storage [$BASEDIR]
--clamav-host value                  clamav-host [$CLAMAV_HOST]
--perform-clamav-prescan             perform-clamav-prescan [$PERFORM_CLAMAV_PRESCAN]
--virustotal-key value               virustotal-key [$VIRUSTOTAL_KEY]
--profiler                           enable profiling [$PROFILER]
--http-auth-user value               user for http basic auth [$HTTP_AUTH_USER]
--http-auth-pass value               pass for http basic auth [$HTTP_AUTH_PASS]
--ip-whitelist value                 comma separated list of ips allowed to connect to the service [$IP_WHITELIST]
--ip-blacklist value                 comma separated list of ips not allowed to connect to the service [$IP_BLACKLIST]
--cors-domains value                 comma separated list of domains allowed for CORS requests [$CORS_DOMAINS]
--random-token-length value          (default: 6) [$RANDOM_TOKEN_LENGTH]
--help, -h                           show help

这是我要部署的映像的 Docker 中心:dutchcoders/transfer.sh

这里是GitHub:https://github.com/dutchcoders/transfer.sh

我的集群版本是 1.23.4 完整的部署 YAML 在这里:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: transfer-sh
  namespace: transfer-sh
  labels:
    app: "transfer-sh"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: transfer-sh
  template:
    metadata:
      labels:
        app: transfer-sh
    spec:
      containers:
      - name: transfer-sh
        image: dutchcoders/transfer.sh:latest
        args:
        - "--provider local"
        - "--basedir /tmp"
        ports:
        - containerPort: 8080

我有意没有包含任何持久卷声明。此时我只是在测试以确保容器将 运行.

最初,我认为这可能是某种转义序列问题。在尝试了各种可能逃避这两个破折号的方法之后,什么都没有真正改变。我还尝试设置包含这些参数的环境变量,但这只会导致 --profile 变成 -profile.

的相同行为

如果有人有任何想法,我可以寻求帮助。我现在有点卡住了(尽管仍在排除故障)。我很好奇是否有不同的方式来传递命令标志而不是参数(或者就 k8s 而言可能没有任何区别)。

尝试:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: transfer-sh
  namespace: transfer-sh
  labels:
    app: transfer-sh
spec:
  replicas: 1
  selector:
    matchLabels:
      app: transfer-sh
  template:
    metadata:
      labels:
        app: transfer-sh
    spec:
      containers:
      - name: transfer-sh
        image: dutchcoders/transfer.sh:latest
        args:  # <-- in this case each arg is individual
        - --provider
        - local
        - --basedir
        - /tmp
        ports:
        - containerPort: 8080


NAME          READY   UP-TO-DATE   AVAILABLE   AGE
transfer-sh   1/1     1            1           91s