$ kubectl version
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.6", GitCommit:"9f8ebd171479bec0ada837d7ee641dec2f8c6dd1", GitTreeState:"clean", BuildDate:"2018-03-21T15:21:50Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.6", GitCommit:"9f8ebd171479bec0ada837d7ee641dec2f8c6dd1", GitTreeState:"clean", BuildDate:"2018-03-21T15:13:31Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
requirements.yaml
dependencies:
- name: sonarqube
version: 0.5.0
repository: https://kubernetes-charts.storage.googleapis.com/
尝试安装最新版本的java插件:
values.yaml
plugins:
install:
- "http://central.maven.org/maven2/org/sonarsource/java/sonar-java-plugin/5.3.0.13828/sonar-java-plugin-5.3.0.13828.jar"
但是,我在init容器上收到错误:
$ kubectl logs sonarqube-sonarqube-7b5dfd84cf-sglk5 -c install-plugins
sh: /opt/sonarqube/extensions/plugins/install_plugins.sh: Permission denied
$ kubectl describe po sonarqube-sonarqube-7b5dfd84cf-sglk5
Name: sonarqube-sonarqube-7b5dfd84cf-sglk5
Namespace: default
Node: docker-for-desktop/192.168.65.3
Start Time: Thu, 19 Apr 2018 15:22:04 -0500
Labels: app=sonarqube
pod-template-hash=3618984079
release=sonarqube
Annotations: <none>
Status: Pending
IP: 10.1.0.250
Controlled By: ReplicaSet/sonarqube-sonarqube-7b5dfd84cf
Init Containers:
install-plugins:
Container ID: docker://b090f52b95d36e03b8af86de5a6729cec8590807fe23e27689b01e5506604463
Image: joosthofman/wget:1.0
Image ID: docker-pullable://joosthofman/wget@sha256:74ef45d9683b66b158a0acaf0b0d22f3c2a6e006c3ca25edbc6cf69b6ace8294
Port: <none>
Command:
sh
-c
/opt/sonarqube/extensions/plugins/install_plugins.sh
State: Waiting
Reason: CrashLoopBackOff
exec
有没有办法进入init容器?
我的尝试:
$ kubectl exec -it sonarqube-sonarqube-7b5dfd84cf-sglk5 -c install-plugins sh
error: unable to upgrade connection: container not found ("install-plugins")
更新
@ WarrenStrange的建议:
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
sonarqube-postgresql-59975458c6-mtfjj 1/1 Running 0 11m
sonarqube-sonarqube-685bd67b8c-nmj2t 1/1 Running 0 11m
$ kubectl get pods sonarqube-sonarqube-685bd67b8c-nmj2t -o yaml
...
initContainers:
- command:
- sh
- -c
- 'mkdir -p /opt/sonarqube/extensions/plugins/ && cp /tmp/scripts/install_plugins.sh
/opt/sonarqube/extensions/plugins/install_plugins.sh && chmod 0775 /opt/sonarqube/extensions/plugins/install_plugins.sh
&& /opt/sonarqube/extensions/plugins/install_plugins.sh '
image: joosthofman/wget:1.0
imagePullPolicy: IfNotPresent
name: install-plugins
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/sonarqube/extensions
name: sonarqube
subPath: extensions
- mountPath: /tmp/scripts/
name: install-plugins
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-89d9n
readOnly: true
...
创建从init容器清单中提取的新pod pod。将命令替换为sleep 6000
并执行命令。这可以让你四处寻找。
答案 0 :(得分:3)
问题是容器不存在(请参阅CrashLoopBackOff)。
我使用init容器做的一件事情(假设你有源代码)是在入口点失败睡眠600。至少用于调试。这可以让你执行到容器中来查看失败的原因。
答案 1 :(得分:0)
为此:
$ kubectl logs sonarqube-sonarqube-7b5dfd84cf-sglk5 -c install-plugins
sh: /opt/sonarqube/extensions/plugins/install_plugins.sh: Permission denied
看来Permission denied
是install-plugin
容器内发生的实际错误。您可以通过在本地joosthofman/wget:1.0
上旋转docker run -it --rm joosthofman/wget:1.0 sh
来诊断/ # ls -l /opt/sonarqube/extensions/plugins/install_plugins.sh
ls: /opt/sonarqube/extensions/plugins/install_plugins.sh: No such file or directory
。这将为您提供一个进入容器的外壳程序,以便您可以检出其运行时内容。
我自己做的,一方面,它试图执行的脚本甚至不存在于容器中。
position: fixed;