zoukankan      html  css  js  c++  java
  • Centos7部署kubectl命令行工具(五)

    1、准备二进制包
    [root@linux-node1 ~]# cd /usr/local/src/kubernetes/client/bin
    [root@linux-node1 bin]# cp kubectl /opt/kubernetes/bin/
    2、创建admin证书签名请求
    [root@linux-node1 bin]# cd /usr/local/src/ssl/
    [root@linux-node1 ssl]# vim admin-csr.json
    {
    "CN": "admin",
    "hosts": [],
    "key": {
    "algo": "rsa",
    "size": 2048
    },
    "names": [
    {
    "C": "CN",
    "ST": "BeiJing",
    "L": "BeiJing",
    "O": "system:masters",
    "OU": "System"
    }
    ]
    }
     
    3、生成admin证书和私钥
    [root@linux-node1 ssl]# cfssl gencert -ca=/opt/kubernetes/ssl/ca.pem
    > -ca-key=/opt/kubernetes/ssl/ca-key.pem
    > -config=/opt/kubernetes/ssl/ca-config.json
    > -profile=kubernetes admin-csr.json | cfssljson -bare admin
    [root@linux-node1 ssl]# cp admin*.pem /opt/kubernetes/ssl/
    4、设置集群参数
    [root@linux-node1 ssl]# kubectl config set-cluster kubernetes
    > --certificate-authority=/opt/kubernetes/ssl/ca.pem
    > --embed-certs=true
    > --server=https://192.168.43.21:6443
    Cluster "kubernetes" set.
    5、设置客户端认证参数
    [root@linux-node1 ssl]# kubectl config set-credentials admin
    > --client-certificate=/opt/kubernetes/ssl/admin.pem
    > --embed-certs=true
    > --client-key=/opt/kubernetes/ssl/admin-key.pem
    User "admin" set.
    6、设置上下文参数
    [root@linux-node1 ssl]# kubectl config set-context kubernetes
    > --cluster=kubernetes
    > --user=admin
    Context "kubernetes" created.
    7、设置默认上下文
    [root@linux-node1 ssl]# kubectl config use-context kubernetes
    Switched to context "kubernetes".
    8、使用kubectl工具
    [root@linux-node1 ssl]# kubectl get cs
    NAME STATUS MESSAGE ERROR
    scheduler Healthy ok
    controller-manager Healthy ok
    etcd-0 Healthy {"health": "true"}
    etcd-1 Healthy {"health": "true"}
    etcd-2 Healthy {"health": "true"}
  • 相关阅读:
    Web API中的消息处理程序(Message Handler)
    Web API中的模型验证
    autoconf配置的项目,编译debug版本
    gcc编译工具生成动态库和静态库之一----介绍
    VMware中四种网络连接模式的区别
    vmware虚拟机三种网络模式的区别
    code block自动生成makefile
    centos7 安装 codeblock(rpm)
    利用cbmakegen导出Code::blocks的Makefile
    C/C++程序CPU问题分析
  • 原文地址:https://www.cnblogs.com/xiaoliangxianshen/p/9165527.html
Copyright © 2011-2022 走看看