在gitlab中获取kubernetes部署的状态

时间:2019-04-15 12:41:22

标签: kubernetes gitlab gitlab-ci

我正在尝试设置gitlab管道,该管道将构建并部署到kubernetes。我正在一步一步

// definition.
struct HalfEdge{
    bool old;
    Vertex * origin;
    HalfEdge * pair;
    HalfEdge * prev;
    HalfEdge * next;
    Face * face;
};
struct Vertex{
    bool old;
    QVector3D pos, newPos;
    HalfEdge * edge;
};
struct Face{
    HalfEdge * edge;
};
// the problem splitEgde()
void Mesh::splitEdge(HalfEdge *e){
    HalfEdge * prev = e->prev;
    HalfEdge * next = e->next;
    HalfEdge * p = e->pair;
    Vertex * v = new Vertex();
    v->pos = v->newPos = newVertexPosition[e];
    v->old = false;
    HalfEdge * eNext = new HalfEdge();
    HalfEdge * vOut = new HalfEdge();
    HalfEdge * vIn = new HalfEdge();
    Face * vFace = new Face();
    /******** face A *******/
    // edge
    e->next = eNext;
    eNext->old = false;
    eNext->origin = v;
    eNext->pair = vIn;
    eNext->prev = e;
    eNext->next = prev;
    eNext->face = e->face;
    prev->prev = eNext;
    // vertex
    // face
    e->face->edge = e;
    /******** face A *******/
    /******** face B *******/
    // edge
    vOut->old = true; // !!
    vOut->origin = v;
    vOut->pair = NULL;
    vOut->prev = vIn;
    vOut->next = next;
    vOut->face = vFace;
    next->prev = vOut;
    next->next = vIn;
    next->face = vFace;
    vIn->old = false;
    vIn->origin = prev->origin;
    vIn->pair = eNext;
    vIn->prev = next;
    vIn->next = vOut;
    vIn->face = vFace;
    // vertex
    v->edge = eNext;
    // face
    vFace->edge = vOut;
    /******** face B *******/
    //the rest is updating the data
}

kubectl apply -f Application-k8s-file.yaml

如您所见,我正在使用滚动更新。即使kubernetes部署失败,我仍然看到状态为等待pod。 kubernetes部署失败时,如何确保我的工作失败。

1 个答案:

答案 0 :(得分:2)

检查是否设置了.spec.progressDeadlineSeconds字段。它表示部署控制器在指示部署进度已停止之前等待的秒数。

这将导致kubectl status rollout命令在X秒钟后失败。

kubectl rollout status deployment.v1.apps/nginx-deployment
Waiting for rollout to finish: 2 out of 3 new replicas have been updated...
error: deployment "nginx" exceeded its progress deadline
$ echo $?
1

更多信息:https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#progress-deadline-seconds