kubernetes无法为简单的RC创建pod

时间:2017-11-06 15:43:25

标签: docker kubernetes

我建立了一个本地的一体化Kubernetes环境。我按照以下步骤进行安装。当我尝试创建我的第一个RC时,RC成功创建,但是没有创建pod:

环境:CentOS7

#systemctl disable firewalld
#systemctl stop firewalld
#yum install -y etcd kubernetes
#systemctl start etcd
#systemctl start docker
#systemctl start kube-apiserver
#systemctl start kube-controller-manager
#systemctl start kube-scheduler
#systemctl start kubelet
#systemctl start kube-proxy

所有服务都开始成功。

的MySQL-rc.yaml:

apiVersion: v1
kind: ReplicationController
metadata:
  name: mysql
spec:
  replicas: 1
  selector:
    app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      - name: mysql
        image: mysql
        resources:
          requests:
            memory: "64Mi"
            cpu: "250m"
          limits:
            memory: "128Mi"
            cpu: "500m"
        ports:
        - containerPort: 3306
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "123456"

命令:

[root@terryhu82 yaml]# kubectl create -f mysql-rc.yaml 
replicationcontroller "mysql" created
[root@terryhu82 yaml]# kubectl get rc
NAME      DESIRED   CURRENT   READY     AGE
mysql     1         0         0         48s
[root@terryhu82 yaml]# kubectl get pods
No resources found.
[root@terryhu82 yaml]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED                 STATUS              PORTS               NAMES
[root@terryhu82 yaml]# kubectl get nodes
NAME        STATUS    AGE
127.0.0.1   Ready     23h
[root@terryhu82 yaml]# kubectl describe node 127.0.0.1
Name:           127.0.0.1
Role:           
Labels:         beta.kubernetes.io/arch=amd64
            beta.kubernetes.io/os=linux
            kubernetes.io/hostname=127.0.0.1
Taints:         <none>
CreationTimestamp:  Mon, 06 Nov 2017 00:22:58 +0800
Phase:          
Conditions:
  Type          Status  LastHeartbeatTime           LastTransitionTime          Reason          Message
  ----          ------  -----------------           ------------------          ------          -------
  OutOfDisk         False   Mon, 06 Nov 2017 23:38:05 +0800     Mon, 06 Nov 2017 00:22:58 +0800     KubeletHasSufficientDisk    kubelet has sufficient disk space available
  MemoryPressure    False   Mon, 06 Nov 2017 23:38:05 +0800     Mon, 06 Nov 2017 00:22:58 +0800     KubeletHasSufficientMemory  kubelet has sufficient memory available
  DiskPressure      False   Mon, 06 Nov 2017 23:38:05 +0800     Mon, 06 Nov 2017 00:22:58 +0800     KubeletHasNoDiskPressure    kubelet has no disk pressure
  Ready         True    Mon, 06 Nov 2017 23:38:05 +0800     Mon, 06 Nov 2017 00:23:08 +0800     KubeletReady        kubelet is posting ready status
Addresses:      127.0.0.1,127.0.0.1,127.0.0.1
Capacity:
 alpha.kubernetes.io/nvidia-gpu:    0
 cpu:                   4
 memory:                16416476Ki
 pods:                  110
Allocatable:
 alpha.kubernetes.io/nvidia-gpu:    0
 cpu:                   4
 memory:                16416476Ki
 pods:                  110
System Info:
 Machine ID:            52ac3151ed7d485d98fa44e0da0e817b
 System UUID:           564D434D-F7CF-9923-4B1D-A494E3391AE1
 Boot ID:           148e293c-9631-4421-b55b-115ba72bc1d3
 Kernel Version:        3.10.0-693.5.2.el7.x86_64
 OS Image:          CentOS Linux 7 (Core)
 Operating System:      linux
 Architecture:          amd64
 Container Runtime Version: docker://1.12.6
 Kubelet Version:       v1.5.2
 Kube-Proxy Version:        v1.5.2
ExternalID:         127.0.0.1
Non-terminated Pods:        (0 in total)
  Namespace         Name        CPU Requests    CPU Limits  Memory Requests Memory Limits
  ---------         ----        ------------    ----------  --------------- -------------
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.
  CPU Requests  CPU Limits  Memory Requests Memory Limits
  ------------  ----------  --------------- -------------
  0 (0%)    0 (0%)      0 (0%)      0 (0%)
Events:
  FirstSeen LastSeen    Count   From            SubObjectPath   Type        Reason          Message
  --------- --------    -----   ----            -------------   --------    ------          -------
  13m       13m     1   {kubelet 127.0.0.1}         Normal      Starting        Starting kubelet.
  13m       13m     1   {kubelet 127.0.0.1}         Warning     ImageGCFailed       unable to find data for container /
  13m       13m     6   {kubelet 127.0.0.1}         Normal      NodeHasSufficientDisk   Node 127.0.0.1 status is now: NodeHasSufficientDisk
  13m       13m     6   {kubelet 127.0.0.1}         Normal      NodeHasSufficientMemory Node 127.0.0.1 status is now: NodeHasSufficientMemory
  13m       13m     6   {kubelet 127.0.0.1}         Normal      NodeHasNoDiskPressure   Node 127.0.0.1 status is now: NodeHasNoDiskPressure
  13m       13m     1   {kubelet 127.0.0.1}         Warning     Rebooted        Node 127.0.0.1 has been rebooted, boot id: 148e293c-9631-4421-b55b-115ba72bc1d3

我没有对组件执行任何配置。任何人都可以帮助指导我为什么没有创建pod和容器?我在哪里可以看到日志?

1 个答案:

答案 0 :(得分:0)

运行这个mysql需要173MB内存。你定义了128M作为上限,这就是为什么它没有开始。你可以使用下面的那个。

apiVersion: v1
kind: ReplicationController
metadata:
  name: mysql
spec:
  replicas: 1
  selector:
    app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      - name: mysql
        image: mysql
        resources:
          requests:
            memory: "64Mi"
            cpu: "250m"
          limits:
            memory: "200Mi"
            cpu: "500m"
        ports:
        - containerPort: 3306
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "123456"

htop输出

enter image description here