ContainerError due to Volumes specification

2/14/2020

I am running Kubernetes app and I am getting ContainerError for some unknown reason and it happens when I add:

    volumeMounts:
    - mountPath: /root/.config
      name: google-config
  volumes:
    - name: google-config
      hostPath:
        path: ~/.config

If I remove it, there are no errors with a pod creation. I tried to get logs of description but when I try to run kubectl describe server-app I am getting error: the server doesn't have a resource type "server-app"

My full yaml file looks like this:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: server-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/grpc-backend: "true"
    nginx.ingress.kubernetes.io/secure-backends: "false"
    nginx.ingress.kubernetes.io/auth-url: "http://token-vendor.default.svc.cluster.local/apis/core.token-vendor/v1/token.verify?robots=true"
spec:
  rules:
  - host: "www.endpoints.excellent-guide-267521.cloud.goog"
    http:
      paths:
      - # must match the namespace and service name in the proto
        path: /sensor.TF/
        backend:
          serviceName: server-service
          # must match the port used in server.cc
          servicePort: 50051
---
apiVersion: v1
kind: Service
metadata:
  name: server-service
spec:
  ports:
  - name: grpc-port
    port: 50051
  # the selector is used to link pods to services
  selector:
    app: server-app
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: server
spec:
  # all pods matching this selector belong to this deployment
  selector:
    matchLabels:
      app: server-app
  template:
    metadata:
      # the other side of the link between services and pods
      labels:
        app: server-app
    spec:
      containers:
      - name: server
        securityContext:
          privileged: true
        image: "gcr.io/excellent-guide-267521/server:latest"
        ports:
        # must match the port of the service
        - containerPort: 50051
        env:
        - name: ROS_MASTER_URI
          value: http://127.0.0.1:11311
        - name: ROS_IP
          value: 127.0.0.1
        volumeMounts:
        - mountPath: /root/.config
          name: google-config
      volumes:
        - name: google-config
          hostPath:
            path: ~/.config

What could be wrong? I just need to access the config files in my docker container so I can use the credentials to log in into my cloud.

The output of kubectl get events:

up replica set server-674f764c95 to 1
47m         Normal    ScalingReplicaSet   deployment/server              Scaled up replica set server-7bc6b8689b to 1
26s         Normal    ScalingReplicaSet   deployment/server              Scaled up replica set server-7bc6b8689b to 1

The output of kubectl describe deployment server:

Name:                   server
Namespace:              default
CreationTimestamp:      Fri, 14 Feb 2020 12:23:07 +0100
Labels:                 <none>
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               app=server-app
Replicas:               1 desired | 1 updated | 1 total | 0 available | 1 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app=server-app
  Containers:
   server:
    Image:      gcr.io/excellent-guide-267521/server:latest
    Port:       50051/TCP
    Host Port:  0/TCP
    Environment:
      ROS_MASTER_URI:  http://127.0.0.1:11311
      ROS_IP:          127.0.0.1
    Mounts:
      /root/.config from google-config (rw)
  Volumes:
   google-config:
    Type:          HostPath (bare host directory volume)
    Path:          ~/.config
    HostPathType:  
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      False   MinimumReplicasUnavailable
  Progressing    False   ProgressDeadlineExceeded
OldReplicaSets:  <none>
NewReplicaSet:   server-7bc6b8689b (1/1 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  50m   deployment-controller  Scaled up replica set server-7bc6b8689b to 1

The pod description:

Name:           server-7bc6b8689b-vdcq9
Namespace:      default
Priority:       0
Node:           gke-cloud-robotics-terraform-20200207-1d37b5cb-twjh/10.132.0.2
Start Time:     Fri, 14 Feb 2020 12:23:07 +0100
Labels:         app=server-app
                pod-template-hash=7bc6b8689b
Annotations:    kubernetes.io/limit-ranger: LimitRanger plugin set: cpu request for container server
Status:         Pending
IP:             10.56.1.35
IPs:            <none>
Controlled By:  ReplicaSet/server-7bc6b8689b
Containers:
  server:
    Container ID:   
    Image:          gcr.io/excellent-guide-267521/server:latest
    Image ID:       
    Port:           50051/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       CreateContainerError
    Ready:          False
    Restart Count:  0
    Requests:
      cpu:  100m
    Environment:
      ROS_MASTER_URI:  http://127.0.0.1:11311
      ROS_IP:          127.0.0.1
    Mounts:
      /root/.config from google-config (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-w6nws (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  google-config:
    Type:          HostPath (bare host directory volume)
    Path:          ~/.config
    HostPathType:  
  default-token-w6nws:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-w6nws
    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  Pulling  4m26s (x358 over 84m)  kubelet, gke-cloud-robotics-terraform-20200207-1d37b5cb-twjh  Pulling image "gcr.io/excellent-guide-267521/server:latest"

Replica description:

Name:           server-7bc6b8689b
Namespace:      default
Selector:       app=server-app,pod-template-hash=7bc6b8689b
Labels:         app=server-app
                pod-template-hash=7bc6b8689b
Annotations:    deployment.kubernetes.io/desired-replicas: 1
                deployment.kubernetes.io/max-replicas: 2
                deployment.kubernetes.io/revision: 1
Controlled By:  Deployment/server
Replicas:       1 current / 1 desired
Pods Status:    0 Running / 1 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=server-app
           pod-template-hash=7bc6b8689b
  Containers:
   server:
    Image:      gcr.io/excellent-guide-267521/server:latest
    Port:       50051/TCP
    Host Port:  0/TCP
    Environment:
      ROS_MASTER_URI:  http://127.0.0.1:11311
      ROS_IP:          127.0.0.1
    Mounts:
      /root/.config from google-config (rw)
  Volumes:
   google-config:
    Type:          HostPath (bare host directory volume)
    Path:          ~/.config
    HostPathType:  
Events:            <none>
-- aikhs
kubernetes

0 Answers