【问题标题】:Application is not viewing on web page after kubectl apply commandkubectl apply 命令后,应用程序未在网页上查看
【发布时间】:2020-11-26 21:14:53
【问题描述】:

我正在运行一个名为 RSPM 的应用程序。在 kubectl apply -f 之后成功创建了 pod。但是只有在我运行 kubectl exec -it pod-name /bin/bash 命令后,该应用程序才会显示在网页上。知道为什么会这样吗?特此列出 YAML 文件。

deployment.yaml

apiVersion: apps/v1 
kind: Deployment
metadata:
  name: rspm-db-deployment
spec:
  selector:
    matchLabels:
      app: rspm
  template:
    metadata:
      labels:
        app: rspm
    spec:
      containers:
      - env:
        - name: RSPM_LICENSE
          value: MY LICENSE
        image: rstudio/rstudio-package-manager:latest
        name: rstudio-package-manager
        ports:
        - containerPort: 4242
        volumeMounts:
        - name: test-config
          mountPath: /etc/rstudio-pm/
        resources: {}
        securityContext:
          privileged: true
      volumes:
      - name: test-config
        configMap:
          name: test-config
      restartPolicy: Always
status: {}

---
kind: Service
apiVersion: v1
metadata:
  name: rstudio-pm
spec:
  selector:
    app: rspm
  ports:
  - protocol: TCP
    port: 4242
    targetPort: 4242
    nodePort: 31040
  type: NodePort

这里是 config.yaml 文件

apiVersion: v1
kind: ConfigMap
metadata:
  name: test-config
  labels:
    app: rspm
data:
  rstudio-pm.gcfg: |
    [Server]
    Address = http://testserver.local
    RVersion = /usr/lib64/R
    [HTTP]
    Listen = :4242

任何帮助将不胜感激! 谢谢!

【问题讨论】:

  • 很奇怪,因为没有任何意义将kubectl exec 运行到 pod 中以使其可访问。我认为您需要查看如何构建主映像,看看您是否错过了 Dockefile 中产生此行为的任何步骤。你能分享一个产生相同行为的示例图像吗?
  • 我使用的是默认图片。没有对默认图像进行任何更改。 @koopakiller

标签: linux docker kubernetes deployment yaml


【解决方案1】:

部署清单文件格式不正确,您丢失了 - 在容器中,请尝试:

apiVersion: apps/v1 
kind: Deployment
metadata:
  name: rspm-db-deployment
spec:
  selector:
    matchLabels:
      app: rspm
  template:
    metadata:
      labels:
        app: rspm
    spec:
      containers:
      - image: rstudio/rstudio-package-manager:latest
        name: rstudio-package-manager
        ports:
        - containerPort: 4242
        volumeMounts:
        - name: test-config
          mountPath: /etc/rstudio-pm/
        resources: {}
        securityContext:
          privileged: true
      volumes:
      - name: test-config
        configMap:
          name: test-config
      restartPolicy: Always
status: {}

---
kind: Service
apiVersion: v1
metadata:
  name: rstudio-pm
spec:
  selector:
    app: rspm
  ports:
  - protocol: TCP
    port: 4242
    targetPort: 4242
    nodePort: 31040
  type: NodePort

对我来说,pod 没有启动,我在 pod 中获取了这些日志:

kubectl 记录 rspm-db-deployment-54f66fb6f8-k9845

+ trap deactivate EXIT
+ '[' -z '' ']'
+ '[' -z '' ']'
+ test -f /etc/rstudio-pm/license.lic
+ unset RSPM_LICENSE
+ unset RSPM_LICENSE_SERVER
+ /opt/rstudio-pm/bin/rstudio-pm --config /etc/rstudio-pm/rstudio-pm.gcfg
2020/08/06 15:42:50 Resource limits: {"nofile":{"soft":1048576,"hard":1048576}}
2020/08/06 15:42:50 Starting RStudio Package Manager v1.1.6.1-5
2020/08/06 15:42:50 Using cache version 8
2020/08/06 15:42:50 Using metrics cache version 1
2020/08/06 15:42:50 Loading server configuration from /etc/rstudio-pm/rstudio-pm.gcfg
2020/08/06 15:42:50 Warning: clearing log region activation reloaded. Any temporary log output activation/deactivation has been reset.
2020/08/06 15:42:50 Using data directory: /var/lib/rstudio-pm
2020/08/06 15:42:50 Creating database directory: /var/lib/rstudio-pm/db
2020/08/06 15:42:50 Creating packages directory: /var/lib/rstudio-pm/packages
2020/08/06 15:42:50 Creating cran directory: /var/lib/rstudio-pm/cran
2020/08/06 15:42:50 Creating binaries directory: /var/lib/rstudio-pm/binaries
2020/08/06 15:42:50 Creating cache directory: /var/lib/rstudio-pm/cache
2020/08/06 15:42:50 Creating launcher directory: /var/lib/rstudio-pm/launcher
2020/08/06 15:42:50 Creating metrics directory: /var/lib/rstudio-pm/metrics
2020/08/06 15:42:50 Using launcher directory: /var/lib/rstudio-pm/launcher
2020/08/06 15:42:50 Creating launcher_logs directory: /var/lib/rstudio-pm/launcher/custom_logs
2020/08/06 15:42:50 Creating launcher_logs_user directory: /var/lib/rstudio-pm/launcher/custom_logs/rstudio-pm
2020/08/06 15:42:51 Updating owner to rstudio-pm for launcher directory: /var/lib/rstudio-pm/launcher
2020/08/06 15:42:51 Creating git directory: /var/lib/rstudio-pm/git
2020/08/06 15:42:51 Creating staging directory: /var/lib/rstudio-pm/packages/staging
2020/08/06 15:42:51 Using CRAN.SystemReqsRulesURL: https://rspm-sync.rstudio.com/sysreqs
2020/08/06 15:42:51 Warning: SSL is not configured. Using Package Manager over insecure HTTP is not recommended.
2020/08/06 15:42:51 A new RSPM encryption key was created at '/var/lib/rstudio-pm/rstudio-pm.key'.
2020/08/06 15:42:51 Using HTTP access log: /var/log/rstudio-pm.access.log
2020/08/06 15:42:51 Added trailing slash to the configured server address: http://testserver.local/
2020/08/06 15:42:51 Starting HTTP listener on :4242
2020/08/06 15:42:51 Starting admin service using sock file /var/run/rstudio-pm/rstudio-pm.sock
2020/08/06 15:42:51 Service ready to listen for requests
2020/08/06 15:42:51 Service mode file not found
2020/08/06 15:42:51 Starting RStudio Package Manager Services
2020/08/06 15:42:51 Starting licensing...
2020/08/06 15:42:51 Unable to obtain a valid license: Your RStudio Package Manager license has expired. Please contact your customer success representative or email sales@rstudio.com to obtain a current license.
2020/08/06 15:42:51 Unable to obtain a valid license: Your RStudio Package Manager license has expired. Please contact your customer success representative or email sales@rstudio.com to obtain a current license.
2020/08/06 15:42:51 Usage data enabled.
2020/08/06 15:42:51 R version specified in Server.RVersion cannot be analyzed: /usr/lib64/R: stat /usr/lib64/R: no such file or directory
2020/08/06 15:42:51 Stopping: metrics buffer...
2020/08/06 15:42:51 Stopping: license manager...
2020/08/06 15:42:51 Done Stopping: license manager
2020/08/06 15:42:51 Stopping: metrics janitor...
2020/08/06 15:42:51 Done Stopping: metrics janitor
2020/08/06 15:42:51 Done Stopping: metrics buffer
2020/08/06 15:42:51 Stopped RStudio Package Manager Online Services
2020/08/06 15:42:51 Error running services: Error: Unable to use R on this system: Could not locate an R installation
2020/08/06 15:42:51 Gracefully shutting down, received signal to terminate
2020/08/06 15:42:51 Stopping: signal dumper...
2020/08/06 15:42:51 Done Stopping: signal dumper
2020/08/06 15:42:51 Exited RStudio Package Manager
+ deactivate
+ echo 'Deactivating license ...'
Deactivating license ...
+ /opt/rstudio-pm/bin/license-manager deactivate

【讨论】:

  • 是的,需要许可证。由于是pvt,所以我没有在yaml文件中提及。我添加了“-”,但它仍然无法正常工作。 stackoverflow.com/users/12260159/amar-bessalah
  • 我面临的唯一问题是,我想运行 kubectl exec -it /bin/bash 在浏览器中查看它。当我应用部署文件时,它不会自动出现。
  • 更新了部署文件
  • 如果不执行“kubeclt exec...”会出现什么错误
  • 它说 Rstudio 包管理器服务没有运行。但是当我执行 kubectl exec 时,我可以看到 Rstudio 包管理器正在运行。
猜你喜欢
  • 2019-06-03
  • 2019-07-25
  • 1970-01-01
  • 2019-01-03
  • 1970-01-01
  • 2020-01-01
  • 1970-01-01
  • 2018-12-21
  • 2017-08-24
相关资源
最近更新 更多