crashloopbackoff中的Kubernetes Pod

时间:2020-07-07 18:01:20

标签: docker kubernetes service deployment crashloopbackoff

我是Kubernetes的新手。

以下是我正在运行的Yaml:

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/name: k8-demo-aishwarya
    app.kubernetes.io/version: version1
  name: k8-demo-aishwarya
spec:
  ports:
  - name: http
    port: 80
    targetPort: 80
  selector:
    app.kubernetes.io/name: k8-demo-aishwarya
    app.kubernetes.io/version: version1
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/name: k8-demo-aishwarya
    app.kubernetes.io/version: version1
  name: k8-demo-aishwarya
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: k8-demo-aishwarya
      app.kubernetes.io/version: version1
  template:
    metadata:
      labels:
        app.kubernetes.io/name: k8-demo-aishwarya
        app.kubernetes.io/version: version1
    spec:
      containers:
      - env:
        - name: KUBERNETES_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        image: docker.io/aishvaryaps/spring-boot-on-kubernetes-example:0.12-SNAPSHOT
        imagePullPolicy: IfNotPresent
        name: k8-demo-aishwarya
        ports:
        - containerPort: 80
          name: http
          protocol: TCP

获取crashloopbackoff错误

有人可以引导我吗?

映像没有问题,它可以正常运行,我已经在Docker上对其进行了测试。

Kubernetes荚日志如下

1. Successfully assigned default/k8-demo-aishwarya-fdd8d58c6-lvxp9 to gke-cluster-3-pool-1-997819b9-j3b2
2. Container image "docker.io/aishvaryaps/spring-boot-on-kubernetes-example:0.12-SNAPSHOT" already present on machine
3. Created container k8-demo-aishwarya
4. Started container k8-demo-aishwarya
5. Back-off restarting failed container

2 个答案:

答案 0 :(得分:1)

请检查POD的日志以了解更多详细信息,但是我认为这是由于处理在容器内结束并打印 room.on('participantConnected', participant => { console.log(`Participant connected: ${participant.identity}`); // this.setTimer(); room.participants.forEach(participant => { console.log(`Participant "${participant.identity}" is connected to the Room`); this.participantConnected(participant, room, true); console.log("publish--->>>", participant); }); }); participantConnected =(participant, room, flag) =>{ participant.tracks.forEach(publication => { this.trackPublished(publication, participant, flag); }); // Handle theTrackPublications that will be published by the Participant later. participant.on('trackPublished', publication => { this.trackPublished(publication, participant, flag); }); } trackPublished=(publication, participant, flag)=> { // If the TrackPublication is already subscribed to, then attach the Track to the DOM. if (publication.track) { this.attachTrack(publication.track, participant, flag); } // Once the TrackPublication is subscribed to, attach the Track to the DOM. publication.on('subscribed', track => { this.attachTrack(track, participant, flag); }); // Once the TrackPublication is unsubscribed from, detach the Track from the DOM. publication.on('unsubscribed', track => { this.detachTrack(track, participant, flag); }); } attachTrack=(track, participant, flag)=>{ var mediaContainer = document.getElementById('local-media'); if (flag == true) { if (track.kind === 'video') { const participantdiv = document.createElement('div'); participantdiv.id = participant.sid; remoteparticipantsid = participant.sid console.log("add remote--->>>", participant.sid); participantdiv.appendChild(track.attach()) mediaContainer.appendChild(participantdiv); } } } 所致,因此可以通过日志进行检查。

您可以通过在YAML中添加行来保持pod的运行:

export class AppComponent { 

    types: SelectItem[];

    selectedType: string


    constructor() {
        this.types = [
            {label: 'Button A', value: 'A'},
            {label: 'Button B', value: 'B'}
        ];
}

}

此命令使pod保持运行

<h3 class="first">Choose View</h3>
<p-selectButton [options]="types" [(ngModel)]="selectedType"></p-selectButton>

<p>Selected Type: <span style="font-weight: bold">{{selectedType}}</span></p>







<!-- Switching Mechanism -->

<div [ngSwitch]="'selectedType'">
  <li *ngSwitchCase="A"> <app-component-a></app-component-a>
  <li *ngSwitchCase="B">  <app-component-b></app-component-b>
  <li *ngSwitchDefault><app-component-b></app-component-b>
</div>

答案 1 :(得分:1)

容器正在运行,并且正在打印hello world消息并退出。请参阅下面来自容器的日志。

$ docker ps -a
CONTAINER ID        IMAGE                                                         COMMAND                  CREATED             STATUS                      PORTS               NAMES
2b177abdbae1        aishvaryaps/spring-boot-on-kubernetes-example:0.12-SNAPSHOT   "/bin/sh -c 'java ${…"   12 seconds ago      Exited (0) 10 seconds ago                       dummy


$ docker logs -f 2b1
Hello World by Aishwarya S!

如果要保持容器运行,则容器内的进程应继续运行。您可能需要从一段时间或for循环中打印消息。