rke安装k8s

Installation

RKE is a fast, versatile Kubernetes installer that you can use to install Kubernetes on your Linux hosts. You can get started in a couple of quick and easy steps:

  1. Download the RKE Binary
  2. Prepare the Nodes for the Kubernetes Cluster
  3. Creating the Cluster Configuration File
  4. Deploying Kubernetes with RKE
  5. Interacting with your Kubernetes Cluster

Download the RKE binary

  1. From your workstation, open a web browser and navigate to our RKE Releases page. Download the latest RKE installer applicable to your Operating System:

    • MacOS: rke_darwin-amd64
    • Linux: rke_linux-amd64
    • Windows: rke_windows-amd64.exe
  2. Make the RKE binary that you just downloaded executable. Open Terminal, change directory to the location of the RKE binary, and then run one of the commands below.

    Using Windows?
    The file is already an executable. Skip to Prepare the Nodes for the Kubernetes Cluster.

    # MacOS
    $ chmod +x rke_darwin-amd64
    # Linux
    $ chmod +x rke_linux-amd64
  3. Confirm that RKE is now executable by running the following command:

    # MacOS
    $ ./rke_darwin-amd64 --version
    # Linux
    $ ./rke_linux-amd64 --version

Prepare the Nodes for the Kubernetes cluster

The Kubernetes cluster components are launched using Docker on a Linux distro. You can use any Linux you want, as long as you can install Docker on it.

Review the [OS requirements]({{< baseurl >}}/rke/v0.1.x/en/installation/os/) and configure each node appropriately.

Creating the Cluster Configuration File

RKE uses a cluster configuration file, referred to as cluster.yml to determine what nodes will be in the cluster and how to deploy Kubernetes. There are [many configuration options]({{< baseurl >}}/rke/v0.1.x/en/config-options/) that can be set in the cluster.yml. In our example, we will be assuming the minimum of one [node]({{< baseurl >}}/rke/v0.1.x/en/config-options/nodes) for your Kubernetes cluster.

There are two easy ways to create a cluster.yml:

  • Using our [minimal cluster.yml]({{< baseurl >}}/rke/v0.1.x/en/example-yamls/#minimal-cluster-yml-example) and updating it based on the node that you will be using.
  • Using rke config to query for all the information needed.

Using rke config

To create a new cluster.yml, run rke config and this command prompts you for all the information needed to build your cluster. Review [our cluster configuration options]({{< baseurl >}}/rke/v0.1.x/en/config-options/) to understand what each question means.

./rke_darwin-amd64 config

After answering the list of questions, there is a cluster.yml created in the directory where you launched the rke config command. After the cluster.yml is created, you can edit the file to make any changes.

Creating a Basic cluster.yml
$ rke config --name cluster.yml

After answering the list of questions, there is a cluster.yml created in the directory where you launched the rke config command.

Creating an Empty cluster.yml

If you want an empty cluster.yml template, you can use the --empty flag so that a template is produced, but there are no values in the template.

$ rke config --empty --name cluster.yml
Printing the cluster.yml

Instead of creating a file, you can print the generated configuration to stdout using the --print flag.

$ rke config --print

High Availability

RKE is HA ready, you can specify more than one controlplane node in the cluster.yml file. RKE will deploy master components on all of these nodes and the kubelets are configured to connect to 127.0.0.1:6443 by default which is the address of nginx-proxy service that proxy requests to all master nodes.

To create an HA cluster, specify more than one host with role controlplane.

Deploying Kubernetes with RKE

After you've created your cluster.yml, you can deploy your cluster with a simple command. This command assumes the cluster.yml file is in the same directory as where you are running the command.

# MacOS
$ ./rke_darwin-amd64 up
# Linux
$ ./rke_linux-amd64 up

There will be log statements as the Kubernetes cluster is created.

$ ./rke_darwin-amd64 up
INFO[0000] Building Kubernetes cluster
INFO[0000] [dialer] Setup tunnel for host [10.0.0.1]
INFO[0000] [network] Deploying port listener containers
INFO[0000] [network] Pulling image [alpine:latest] on host [10.0.0.1]
...
INFO[0101] Finished building Kubernetes cluster successfully

The last line should read Finished building Kubernetes cluster successfully to indicate that your cluster is ready to use. As part of the Kubernetes creation process, a kubeconfig file has been created and written at kube_config_cluster.yml, which can be used to start interacting your Kubernetes cluster.

Interacting with your Kubernetes cluster

In order to start interacting with your Kubernetes cluster, you will use a different binary called kubectl. You will need to install kubectl on your local machine. You can connect to the RKE created cluster by using the kube_config_cluster.yml that was generated when you deployed Kubernetes.

# Confirm that kubectl is working by checking the version of your Kubernetes cluster
$ kubectl --kubeconfig kube_config_cluster.yml version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03-27T00:13:02Z", GoVersion:"go1.9.4", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"8+", GitVersion:"v1.8.9-rancher1", GitCommit:"68595e18f25e24125244e9966b1e5468a98c1cd4", GitTreeState:"clean", BuildDate:"2018-03-13T04:37:53Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

The client and server version are reported, indicating that you have a local kubectl client and are able to request the server version from the newly built cluster. Now, you can issue any kubectl command to your cluster, like requesting the nodes that are in the cluster.

$ kubectl --kubeconfig kube_config_cluster.yml get nodes
NAME            STATUS    ROLES                      AGE       VERSION
10.0.0.1         Ready     controlplane,etcd,worker   35m       v1.10.3-rancher1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值