kubernetes若干问题

kubernetes若干问题

在将fabric compose启动方法转为k8s启动方法中,遇到的各种问题.
  • Q1: kubernetes exec 访问不到pod

    root@liu:~/dns# kubectl exec -it busybox date
    Error from server: error dialing backend: dial tcp 172.16.199.55:10250: connect: connection refused
  • A:修改本机host或者修改kubelet启动参数

      该问题主要与配置的启动参数有关,搭建的是一个solo集群,master和node在一个宿          主机器上,并且配置的kubelet地址参数为127.0.0.1,而本机器的host记录的是本地的  
    私有地址172.16.199.55,这就造成了访问不通的问题.
    
    • 方法1:修改本机host

      root@liu:~# hostname
      liu
      root@liu:~# cat /etc/hosts
      127.0.0.1   localhost
      
       # The following lines are desirable for IPv6 capable hosts
      ::1 localhost   ip6-localhost   ip6-loopback
      ff02::1 ip6-allnodes
      ff02::2 ip6-allrouters
      172.16.199.55   liu 
      
       #修改172.16.199.55   liu 为 127.0.0.1 liu
       #或者 在 127.0.0.1 localhost 后加上hostname
       #127.0.0.1 localhost  liu
      root@liu:~# ping liu
      PING localhost (127.0.0.1) 56(84) bytes of data.
      64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.035 ms
      ^C
       #访问容器
      root@liu:~/dns# kubectl exec -it busybox date
      Thu Aug 30 07:15:50 UTC 2018
    • 方法2: 修改kubelet启动参数

      root@liu:~# cat /etc/kubernetes/kubelet
      
       ## The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)
      KUBELET_ADDRESS="--address=127.0.0.1"
       #修改KUBELET_ADDRESS="--address=127.0.0.1"为
       #KUBELET_ADDRESS="--address=172.16.199.55" 
       #重新启动kubelet服务
      root@liu:~# systemctl restart kubelet.service 
       #访问容器
      root@liu:~/dns# kubectl exec -it busybox date
      Thu Aug 30 07:15:50 UTC 2018
      
    • 参考:Error from server: error dialing backend: dial tcp: lookup xxx on 114.114.114.114:53: no such
    • 解决过程:

        开始以为是没有配置DNS的问题,但是后来想,第一个实例(guestbook)已经跑通,所  
      以,内部DNS是正确的,外部访问可以kubectl get node/pod都正确,甚至配置了CNI,  
      问题依旧.
        之前也查到说修改host,但是,我这是solo集群,为什么还需要配置host?于是认为  
      可能是添加pod,仍然不对.偶然间看到别人多主机集群也有这个问题,并通过添加节点  
      host解决该问题.
        于是,hostname查看我的主机名为liu,ping了一下主机名,显示172.16.199.55,  
      再想到我配置的地址参数一般是127.0.0.1,随即/etc/hosts添加127.0.0.1 liu,  
      访问容器反馈了正确结果.
        最后查到是kubelet启动参数:--address=127.0.0.1的问题.
      
  • Q2: v1.EnvVar.Value: ReadString: expects ” or n, but found t, error found in #10 byte of …|,”value”:true}]

    root@liu:~/work/e2e_cli_k8s/fabric_orderer# kubectl create -f orderer-deployment.yaml 
    Error from server (BadRequest): error when creating "orderer-deployment.yaml": Deployment in version "v1beta1" cannot be handled as a Deployment: v1beta1.Deployment.Spec: v1beta1.DeploymentSpec.Template: v1.PodTemplateSpec.Spec: v1.PodSpec.Containers: []v1.Container: v1.Container.Env: []v1.EnvVar: v1.EnvVar.Value: ReadString: expects " or n, but found t, error found in #10 byte of ...|,"value":true}],"ima|..., bigger context ...|":"30s"},{"name":"ORDERER_KAFKA_VERBOSE","value":true}],"image":"hyperledger/fabric-orderer","imageP|...   
    
    root@liu:~/work/e2e_cli_k8s/fabric_orderer# cat orderer-deployment.yaml 
    ---
    
    kind: Deployment
    apiVersion: extensions/v1beta1
    - name: ORDERER_KAFKA_VERBOSE
     #...   
     env: 
     #...       
     - name: ORDERER_GENERAL_TLS_PRIVATEKEY
       value: '/var/hyperledger/orderer/tls/server.key'
     - name: ORDERER_GENERAL_TLS_CERTIFICATE
       value: '/var/hyperledger/orderer/tls/server.crt'
     - name: ORDERER_GENERAL_TLS_ROOTCAS
       value: '[/var/hyperledger/orderer/tls/ca.crt]'
     - name: ORDERER_KAFKA_RETRY_SHORTINTERVAL
       value: 1s
     - name: ORDERER_KAFKA_RETRY_SHORTTOTAL
       value: 30s
     - name: ORDERER_KAFKA_VERBOSE
       value: true 
    
  • A:kubernetes的env label value只支持string
    • Unable to create an object when label value is not a string
    • Docker how to use boolean value on spec.container.env.value

你可能感兴趣的:(云计算/大数据)