在kubectl应用后,广告连播卡在未决状态吗?

时间:2019-06-14 12:25:55

标签: docker ubuntu kubernetes

我的豆荚在kubectl应用后保持待处理状态。我目前正在尝试部署3个服务,即postgres数据库,api服务器和应用程序的ui。postgrespod运行正常,但其余2个服务处于待处理状态。

我尝试创建这样的Yaml文件

api服务器持久性卷

CREATE OR REPLACE PROCEDURE p_get_job_run_details_test (p_details OUT sys_refcursor) AS
  l_start_date TIMESTAMP;
  date1        TIMESTAMP;
  l_end_date   TIMESTAMP;
  l_count      INTEGER;
  p_start_date varchar2(20);
  p_end_date   varchar2(20);
BEGIN
  p_start_date := '11-JUN-2019';
  p_end_date   := '11-JUN-2019';

  select to_timestamp_tz(p_start_date || ' 00:00:00 EUROPE/PARIS', 'DD-MON-YYYY HH24:MI:SS TZR')
    into l_start_date
    from dual;

    select to_timestamp_tz(p_end_date || ' 23:59:59 EUROPE/PARIS', 'DD-MON-YYYY HH24:MI:SS TZR')
    into l_end_date
    from dual;
  dbms_output.put_line(to_char(l_start_date, 'YYYY-MM-DD HH24:MI:SS') || '|' || to_char(l_end_date, 'YYYY-MM-DD HH24:MI:SS'));

  select count(*)
    into l_count
    FROM all_scheduler_job_run_details
   WHERE job_name = 'RANDOM_JOB'
     and log_date >= l_start_date
     and log_date <= l_end_date
     ;

  dbms_output.put_line(l_count);
    OPEN p_details FOR
      SELECT owner, log_date, job_subname,
             status, error# as error, req_start_date, actual_start_date,
             run_duration, additional_info
        FROM user_scheduler_job_run_details
       WHERE log_date >= l_start_date
         AND log_date <= l_end_date
         AND job_name = 'RANDOM_JOB'
       ORDER BY log_date DESC;

END p_get_job_run_details_test;

api服务器

kind: PersistentVolume
apiVersion: v1
metadata:
  name: api-initdb-pv-volume
  labels:
    type: local
    app: api
spec:
  storageClassName: manual
  capacity:
    storage: 1Mi
  accessModes:
    - ReadOnlyMany
  hostPath:
    path: "/home/vignesh/pagedesigneryamls/api"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: api-initdb-pv-claim-one
  labels:
    app: api
spec:
  storageClassName: manual
  accessModes:
    - ReadOnlyMany
  resources:
    requests:
      storage: 1Mi

docker-compose文件(仅供参考)


apiVersion: v1
kind: Service
metadata:
  name: apiserver
  labels:
    app: apiserver
spec:

  ports:
  - name: apiport
    port: 8000
    targetPort: 8000

  selector:
    app: apiserver
    tier: backend    

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: apiserver
  labels:
    app: apiserver
spec:
  selector:
    matchLabels:
      app: apiserver
      tier: backend
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: apiserver
        tier: backend
    spec:

      containers:
      - image: suji165475/devops-sample:wootz-backend
        name: apiserver
        ports:
        - containerPort: 8000
          name: myport
        volumeMounts:
        - name: api-persistent-storage-one
          mountPath: /usr/src/app
        - name: api-persistent-storage-two
          mountPath: /usr/src/app/node_modules  
      volumes:
      - name: api-persistent-storage-one
        persistentVolumeClaim:
          claimName: api-initdb-pv-claim-one
      - name: api-persistent-storage-two
        persistentVolumeClaim:
          claimName: api-initdb-pv-claim-two 

当我尝试在api服务器yaml文件上应用kubectl时,api服务器的pod一直卡在待命状态。我该如何解决。

2 个答案:

答案 0 :(得分:0)

对于将来的问题,如果您需要更多有关正在发生的事情的信息,则应该使用kubectl describe pod_name,因为这将为您和我们提供更多的信息,并会增加适当答案的机会。我用了您的Yaml,并在描述了豆荚之后:

persistentvolumeclaim "api-initdb-pv-claim-two" not found

添加第二个后:

pod has unbound PersistentVolumeClaims (repeated 3 times)

添加第二个PV后,它应该开始工作。

您有两个永久卷声明,只有一个永久卷。您不能将两个PVC绑定到PV。因此,在这种情况下,您需要向清单添加另一个PV和另一个PVC。

您可以详细了解here

  

PersistentVolume(PV)是原子抽象。你不能   将其细分为多个索赔。

有关持久卷及其工作方式的更多信息,请参见官方documentation

此外,如果您尝试部署PostgresSQL here,则是有关如何执行此操作的良好指南。另外一个因为使用托管Kubernetes服务而更容易-how to run HA PostgreSQL on GKE

答案 1 :(得分:0)

api-initdb-pv-claim-两个pvc不存在。

您需要创建pv,并使用一个pvc将其绑定