我的kubernetes yaml文件创建成功,但是容器显示错误,这里是yaml文件供参考,基本上是一个多容器,在yaml文件中定义了内存限制
apiVersion: batch/v1
kind: Job
metadata:
name: command-demo
spec:
ttlSecondsAfterFinished: 100
template:
spec:
volumes:
- name: docker-sock
emptyDir: {}
restartPolicy: Never
containers:
- name: command-demo-container
image: tarunkumard/fromscratch6.0
volumeMounts:
- mountPath: /opt/gatling-fundamentals/build/reports/gatling/
name: docker-sock
imagePullPolicy: Never
resources:
requests:
memory: "950Mi"
limits:
memory: "1Gi"
- name: ubuntu
image: ubuntu:16.04
command: [ "/bin/bash", "-c", "--" ]
args: [ "while true; do sleep 10; done;" ]
volumeMounts:
- mountPath: /docker-sock
name: docker-sock
imagePullPolicy: Never
env:
- name: JVM_OPTS
value: "-Xms950M -Xmx1G"
尝试以下命令
vagrant@ubuntu-xenial:~/pods$ kubectl create -f gat.yaml
job.batch/command-demo created
vagrant@ubuntu-xenial:~/pods$ kubectl get pods
NAME READY STATUS RESTARTS AGE
command-demo-bptqj 1/2 Error 0 2m33s
这里是describe pod的输出
vagrant@ubuntu-xenial:~/pods$ kubectl describe pods command-demo-bptqj
Name: command-demo-bptqj
Namespace: default
Node: ip-172-31-8-145/172.31.8.145
Start Time: Thu, 17 Jan 2019 02:03:28 +0000
Labels: controller-uid=152e2655-19fc-11e9-b787-02d8b37d95a0
job-name=command-demo
Annotations: kubernetes.io/limit-ranger: LimitRanger plugin set: memory request for container ubuntu; memory limit for container ubuntu
Status: Running
IP: 10.1.40.91
Controlled By: Job/command-demo
Containers:
command-demo-container:
Container ID: docker://108004b18788b8410a9ecd0ebb06242463b5e12b193ed3f9d54fe99d1fd1f6b1
Image: tarunkumard/fromscratch6.0
Image ID: docker-pullable://tarunkumard/fromscratch6.0@sha256:94cc06dde5e242c23e03742365d48008a9a31ffd9d79593838ebb4d651d932c9
Port: <none>
Host Port: <none>
State: Terminated
Reason: Error
Exit Code: 2
Started: Thu, 17 Jan 2019 02:03:30 +0000
Finished: Thu, 17 Jan 2019 02:03:30 +0000
Ready: False
Restart Count: 0
Limits:
memory: 1Gi
Requests:
memory: 950Mi
Environment: <none>
Mounts:
/opt/gatling-fundamentals/build/reports/gatling/ from docker-sock (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-w6jt6 (ro)
ubuntu:
Container ID: docker://fdedb595698ae6697ee3ac9bbf01d25e073bc3d6342a0d14c54a427264f1175d
Image: ubuntu:16.04
Image ID: docker-pullable://ubuntu@sha256:e547ecaba7d078800c358082088e6cc710c3affd1b975601792ec701c80cdd39
Port: <none>
Host Port: <none>
Command:
/bin/bash
-c
--
Args:
while true; do sleep 10; done;
State: Running
Started: Thu, 17 Jan 2019 02:03:30 +0000
Ready: True
Restart Count: 0
Limits:
memory: 1Gi
Requests:
memory: 1Gi
Environment:
JVM_OPTS: -Xms950M -Xmx1G
Mounts:
/docker-sock from docker-sock (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-w6jt6 (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
docker-sock:
Type: EmptyDir (a temporary directory that shares a pod's lifetime)
Medium:
default-token-w6jt6:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-w6jt6
Optional: false
QoS Class: Burstable
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 5m32s default-scheduler Successfully assigned default/command-demo-bptqj to ip-172-31-8-145
Normal Pulled 5m31s kubelet, ip-172-31-8-145 Container image "tarunkumard/fromscratch6.0" already present on machine
Normal Created 5m30s kubelet, ip-172-31-8-145 Created container
Normal Started 5m30s kubelet, ip-172-31-8-145 Started container
Normal Pulled 5m30s kubelet, ip-172-31-8-145 Container image "ubuntu:16.04" already present on machine
Normal Created 5m30s kubelet, ip-172-31-8-145 Created container
Normal Started 5m30s kubelet, ip-172-31-8-145 Started container
我怎么知道容器到底有什么问题或如何查看日志
答案 0 :(得分:1)
嘿玛格丽特,其余的人都可以使用kubectl。
另外,您可以将ssh放入worker节点,并在容器上进行docker检查以查看一些其他日志。
如果所有这些都不能满足您的需求,您可以kubectl exec -it {pod_name}
将其带到Docker容器的交互式终端,您可以在其中检查/ var / logs /或其他相关的OS日志。
答案 1 :(得分:0)
从具有多个容器的pod nginx返回快照日志:
$ kubectl logs podname --all-containers=true
从pod Nginx返回带有指定容器的快照日志:
$ kubectl logs podname -c container-name
答案 2 :(得分:0)
要查看pod的先前容器日志,请执行以下操作:
func setupRandomScene() {
self.scene.rootNode.childNodes.forEach({ (node) in
node.removeFromParentNode()
})
DispatchQueue.main.async {
if !Model.shared.hasSeenTooltips {
self.scene = SCNScene(named: "art.scnassets/levels/level\(0).scn")!
} else {
switch Model.shared.level {
case 1...10:
let randomInt = Int.random(in: 1...8)
self.scene = SCNScene(named: "art.scnassets/levels/level\(randomInt).scn")!
case 11...20:
let randomInt = Int.random(in: 1...16)
self.scene = SCNScene(named: "art.scnassets/levels/level\(randomInt).scn")!
default:
let randomInt = Int.random(in: 9...40)
self.scene = SCNScene(named: "art.scnassets/levels/level\(randomInt).scn")!
}
}
let randomColorInt = Int.random(in: 1...4)
switch randomColorInt {
case 1:
self.scene.background.contents = UIImage(named: "art.scnassets/bg/purple")
case 2:
self.scene.background.contents = UIImage(named: "art.scnassets/bg/pink")
case 3:
self.scene.background.contents = UIImage(named: "art.scnassets/bg/orange")
case 4:
self.scene.background.contents = UIImage(named: "art.scnassets/bg/teal")
case 5:
self.scene.background.contents = UIImage(named: "art.scnassets/bg/cyan")
default:
self.scene.background.contents = UIImage(named: "art.scnassets/bg/blue")
}
self.scene.rootNode.childNode(withName: "road", recursively: true)?.geometry?.materials.first?.diffuse.contents = UIColor.black
self.scene.rootNode.childNode(withName: "finishPlatform", recursively: true)?.geometry?.materials.first?.diffuse.contents = UIColor.black
self.scene.rootNode.addChildNode(self.cameraNode)
self.scene.physicsWorld.contactDelegate = self
self.scene.physicsWorld.gravity = SCNVector3(0, -9.8, 0)
self.playerNode = SCNNode()
self.setupPlayerNode()
self.setupSounds()
self.dancingAnimation = SCNAnimation(named: "art.scnassets/stickman/dance\(Int.random(in: 1...10)).scnanim")
let directionalLight = SCNNode()
directionalLight.name = "directional"
directionalLight.position = SCNVector3(-10, 50, -100)
directionalLight.light = SCNLight()
directionalLight.light?.type = .directional
directionalLight.light?.castsShadow = true
directionalLight.light?.shadowRadius = 2 // 1000
directionalLight.light?.shadowSampleCount = 20 // 20
directionalLight.light?.shadowMapSize = CGSize(width: 2000, height: 2000)
directionalLight.light?.intensity = 2000
directionalLight.eulerAngles = SCNVector3(0, -toRadians(angle: 150), -toRadians(angle: 60))
self.scene.rootNode.addChildNode(directionalLight)
let ambientLight = SCNNode()
ambientLight.name = "ambient"
ambientLight.light = SCNLight()
ambientLight.light?.castsShadow = false
ambientLight.light?.type = .ambient
ambientLight.light?.color = UIColor.darkGray
ambientLight.light?.intensity = 5000
self.scene.rootNode.addChildNode(ambientLight)
self.cameraNode.position = SCNVector3(self.playerNode.position.x, self.playerNode.position.y + 5, self.playerNode.position.z - 9)
self.cameraNode.eulerAngles = SCNVector3(-toRadians(angle: 5), -toRadians(angle: 180), 0)
self.cameraNode.camera = SCNCamera()
self.gameState = .menu
self.scnView = nil
self.scnView = self.view as? SCNView
if let _ = self.scnView {
self.scnView!.delegate = self
self.overlayScene = OverlayScene(with: self.overlaySceneSize, isLive: self.broadcastController.isBroadcasting)
self.scnView!.overlaySKScene = self.overlayScene
self.scnView!.present(self.scene, with: .fade(with: .white, duration: 1), incomingPointOfView: nil, completionHandler: nil)
}
if !Model.shared.soundIsMuted {
self.playerNode.runAction(self.playWooshSound)
}
self.positiveHaptic.prepare()
}
}