In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to install Kubernetes". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to install Kubernetes.
Installation process
The installation process includes downloading the software, downloading the image, configuring the host, starting the Master node, configuring the network, and starting the Node node.
Download software
People who have the ability to climb over the wall in this step can follow the steps directly, and if not, they can use the 1.6.2 package I packaged.
First of all, configure the K8S source on your own wall-climbing host.
Cat / proc/sys/net/bridge/bridge-nf-call-iptables install K8S package
Upload the RPM package to your own server, and then execute
Yum install-y * .rpm
After that, turn on the boot of kubelet
Systemctl enable kubelet
Then configure kubelet and modify / etc/systemd/system/kubelet.service.d/10-kubeadm.conf to the following file
[Service] Environment= "KUBELET_KUBECONFIG_ARGS=--kubeconfig=/etc/kubernetes/kubelet.conf-require-kubeconfig=true" Environment= "KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests-allow-privileged=true" Environment= "KUBELET_NETWORK_ARGS=--network-plugin=cni-cni-conf-dir=/etc/cni/net.d-cni-bin-dir=/opt/cni/bin" Environment= "KUBELET_DNS_ARGS=--cluster-dns=10.96.0.10-cluster-domain=cluster. Local "Environment=" KUBELET_AUTHZ_ARGS=--authorization-mode=Webhook-client-ca-file=/etc/kubernetes/pki/ca.crt "Environment=" KUBELET_ALIYUN_ARGS=--pod-infra-container-image=registry-vpc.cn-beijing.aliyuncs.com/bbt_k8s/pause-amd64:3.0 "ExecStart=ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_SYSTEM_PODS_ARGS $KUBELET_NETWORK_ARGS $KUBELET_DNS_ARGS $KUBELET_AUTHZ_ARGS $KUBELET_EXTRA_ARGS $KUBELET_ALIYUN_ARGS
Here, we mainly fix two problems, one is to modify the basic container of POD to our own source, and the other is that there is a conflict between the resource management of the latest version of K8S and the default resource management mode of Docker. This piece has been deleted here. For more information, please refer to https://github.com/kubernetes/release/issues/306
Then re-reload the service.
Systemctl daemon-reload
This completes the initialization of the host environment. If you are using a virtual machine, just make 3 copies. If it is a physical machine, it would be nice for all three to follow this step. Then set the HostName,K8S for each host according to the type and use HostName as the host ID.
Start Master
After configuring the host, we can start our Master node, usually 2-3 Master nodes are recommended, and local testing is easier for us, one node is fine.
Export KUBE_REPO_PREFIX= "registry-vpc.cn-beijing.aliyuncs.com/bbt_k8s" export KUBE_ETCD_IMAGE= "registry-vpc.cn-beijing.aliyuncs.com/bbt_k8s/etcd-amd64:3.0.17" kubeadm init-kubernetes-version=v1.6.2-pod-network-cidr=10.96.0.0/12
The first two environment variables are configured to use our mirror source to download the image when kubeadm is initialized.
Finally, kubeadm init initializes the Master node. Let me explain the parameters that need to be configured.
Note on the meaning of the parameter-the version number of kubernetes-versionK8S, which is selected according to the downloaded image and RPM version. I use 1.6.2 here, so the network version of v1.6.2.--pod-network-cidrPOD is fine as long as it does not conflict with the host network. I use 10.96.0.0 KUBELET_DNS_ARGS 12 here, which is linked to the KUBELET_DNS_ARGS declared in / etc/systemd/system/kubelet.service.d/10-kubeadm.conf above. Please modify it together.
After the execution is finished, wait for a while, and it will be finished.
Kubeadm init-- kubernetes-version=v1.6.2-- pod-network-cidr=10.96.0.0/12 [kubeadm] WARNING: kubeadm is in beta Please do not use it for production clusters. [init] Using Kubernetes version: v1.6.2 [init] Using Authorization mode: RBAC [preflight] Running pre-flight checks [preflight] Starting the kubelet service [certificates] Generated CA certificate and key. [certificates] Generated API server certificate and key. [certificates] API Server serving cert is signed for DNS names [node0 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.61.41] [certificates] Generated API server Kubelet client certificate and key. [certificates] Generated service account token signing key and public key. [certificates] Generated front-proxy CA certificate and key. [certificates] Generated front-proxy client certificate and key. [certificates] Valid certificates and keys now exist in "/ etc/kubernetes/pki" [kubeconfig] Wrote KubeConfig file to disk: "/ etc/kubernetes/admin.conf" [kubeconfig] Wrote KubeConfig file to disk: "/ etc/kubernetes/kubelet.conf" [kubeconfig] Wrote KubeConfig file to disk: "/ etc/kubernetes/controller-manager .conf "[kubeconfig] Wrote KubeConfig file to disk:" / etc/kubernetes/scheduler.conf "[apiclient] Created API client Waiting for the control plane to become ready [apiclient] All control plane components are healthy after 14.583864 seconds [apiclient] Waiting for at least one node to register [apiclient] First node has registered after 6.008990 seconds [token] Using token: e7986d.e440de5882342711 [apiconfig] Created RBAC rules [addons] Created essential addon: kube-proxy [addons] Created essential addon: kube-dnsYour Kubernetes master has initialized successfully!To start using your cluster You need to run (as a regular user): sudo cp / etc/kubernetes/admin.conf $HOME/ sudo chown $(id-u): $(id-g) $HOME/admin.conf export KUBECONFIG=$HOME/admin.confYou should now deploy a podnetwork to the cluster.Run "kubectl apply-f [podnetwork] .yaml" with one of the options listed at: http://kubernetes.io/docs/admin/addons/You can now join any number of machines by running the following on each nodeas root: kubeadm join-- token 1111.1111111111111 *. *: 6443
After the installation is complete, it is very important to check the installation log and copy a statement similar to the following, which is used to initialize the node.
Kubeadm join-- token 11111.1111111111111111 *. *: 6443
Then we can go to see the status of our K8S. I am using Mac. Linux and Windows's classmates handled it on their own.
Install kubectl
Brew install kubectl
Then copy the / etc/kubernetes/admin.conf file on the Master node to the native ~ / .kube/config
Kebectl get node is then executed. I have already installed it here, so I have all the information, as long as I can see the node, it is a success.
Install network components
Next, let's install the network components, and I'm using flannel here. Create 2 files
Kube-flannel-rbac.yml
# Create the clusterrole and clusterrolebinding:# $kubectl create-f kube-flannel-rbac.yml# Create the pod using the same namespace used by the flannel serviceaccount:# $kubectl create-- namespace kube-system-f kube-flannel.yml---kind: ClusterRoleapiVersion: rbac.authorization.k8s.io/v1beta1metadata: name: flannelrules:-apiGroups:-"" resources:-pods verbs:-get-apiGroups:-"" resources:- Nodes verbs:-list-watch-apiGroups:-"" resources:-nodes/status verbs:-patch---kind: ClusterRoleBindingapiVersion: rbac.authorization.k8s.io/v1beta1metadata: name: flannelroleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: flannelsubjects:- kind: ServiceAccount name: flannel namespace: kube-system
Kube-flannel-ds.yaml
-apiVersion: v1kind: ServiceAccountmetadata: name: flannel namespace: kube-system---kind: ConfigMapapiVersion: v1metadata: name: kube-flannel-cfg namespace: kube-system labels: tier: node app: flanneldata: cni-conf.json: | {"name": "cbr0", "type": "flannel" "delegate": {"isDefaultGateway": true}} net-conf.json: | {"Network": "10.96.0.0amp12" "Backend": {"Type": "vxlan"}}-apiVersion: extensions/v1beta1kind: DaemonSetmetadata: name: kube-flannel-ds namespace: kube-system labels: tier: node app: flannelspec: template: metadata: labels: tier: node app: flannelspec: hostNetwork: true nodeSelector: beta.kubernetes.io/arch: amd64 tolerations: -key: node-role.kubernetes.io/master operator: Exists effect: NoSchedule serviceAccountName: flannel containers:-name: kube-flannel image: registry.cn-beijing.aliyuncs.com/bbt_k8s/flannel:v0.7.0-amd64 command: ["/ opt/bin/flanneld" "- ip-masq" "- kube-subnet-mgr"] securityContext: privileged: true env:-name: POD_NAME valueFrom: fieldRef: fieldPath: metadata.name-name: POD_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace volumeMounts:-name: run MountPath: / run-name: flannel-cfg mountPath: / etc/kube-flannel/-name: install-cni image: registry.cn-beijing.aliyuncs.com/bbt_k8s/flannel:v0.7.0-amd64 command: ["/ bin/sh" "- c", "set-e-x Cp-f / etc/kube-flannel/cni-conf.json / etc/cni/net.d/10-flannel.conf; while true; do sleep 3600 Done "] volumeMounts:-name: cni mountPath: / etc/cni/net.d-name: flannel-cfg mountPath: / etc/kube-flannel/ volumes:-name: run hostPath: path: / run-name: cni hostPath: path: / etc/cni/net.d -name: flannel-cfg configMap: name: kube-flannel-cfg
Then use the use command to configure.
Kubectl create-f kube-flannel-rbac.ymlkubectl create-f kube-flannel-ds.yaml starts Node
On each of the two Node nodes, execute the following command.
Export KUBE_REPO_PREFIX= "registry-vpc.cn-beijing.aliyuncs.com/bbt_k8s" export KUBE_ETCD_IMAGE= "registry-vpc.cn-beijing.aliyuncs.com/bbt_k8s/etcd-amd64:3.0.17" kubeadm join-- token 1111.111111111111 *. *: 6443
For kubeadm join, please refer to the contents of launching Master node.
Other
In theory, when we install it here, K8S is ready to use. The next step is mainly the installation of Dashboard for K8S, which is for reference only, not necessarily.
Install DashBoard tools
Create a file kubernetes-dashboard.yaml
# Copyright 2015 Google Inc. All Rights Reserved.## Licensed under the Apache License, Version 2.0 (the "License") # you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "ASIS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND Either express or implied.# See the License for the specific language governing permissions and# limitations under the License.# Configuration to deploy release version of the Dashboard UI compatible with# Kubernetes 1. 6 (RBAC enabled). # # Example usage: kubectl create-f apiVersion: v1kind: ServiceAccountmetadata: labels: app: kubernetes-dashboard name: kubernetes-dashboard namespace: kube-system---apiVersion: rbac.authorization.k8s.io/v1beta1kind: ClusterRoleBindingmetadata: name: kubernetes-dashboard labels: app: kubernetes-dashboardroleRef: apiGroup: rbac.authorization.k8s .io kind: ClusterRole name: cluster-adminsubjects:- kind: ServiceAccount name: kubernetes-dashboard namespace: kube-system---kind: DeploymentapiVersion: extensions/v1beta1metadata: labels: app: kubernetes-dashboard name: kubernetes-dashboard namespace: kube-systemspec: replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: kubernetes-dashboard template: metadata: labels: app: kubernetes-dashboard spec: containers:-name: kubernetes-dashboard image: Registry.cn-beijing.aliyuncs.com/bbt_k8s/kubernetes-dashboard-amd64:v1.6.0 imagePullPolicy: Always ports:-containerPort: 9090 protocol: TCP args: # Uncomment the following line to manually specify Kubernetes API server Host # If not specified Dashboard will attempt to auto discover the API server and connect # to it. Uncomment only if the default does not work. #-apiserver-host= http://my-address:port livenessProbe: httpGet: path: / port: 9090 initialDelaySeconds: 30 timeoutSeconds: 30 serviceAccountName: kubernetes-dashboard # Comment the following tolerations if Dashboard must not be deployed on master tolerations:-key: node-role.kubernetes.io/master effect: NoSchedule---kind: ServiceapiVersion: v1metadata: Labels: app: kubernetes-dashboard name: kubernetes-dashboard namespace: kube-systemspec: type: NodePort ports:-port: 80 targetPort: 9090 selector: app: kubernetes-dashboard
Create a file dashboard-rbac.yaml
Kind: ClusterRoleBindingapiVersion: rbac.authorization.k8s.io/v1beta1metadata: name: dashboard-adminroleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects:- kind: ServiceAccount name: default namespace: kube-system
Execute after
Kubectl create-f dashboard-rbac.ymlkubectl create-f kubernetes-dashboard.yaml
Then use the following command to get the corresponding port number. Mainly look at things like NodePort: 31867/TCP. Then access it using http://NodeIp:NodePort, where NodeIp is Master or IP,NodePort of Node is the port of NodePort.
Kubectl describe-namespace kube-system service kubernetes-dashboard
At this point, this installation tutorial ends here. Finally, we send you a screenshot of the installation.
At this point, I believe you have a deeper understanding of "how to install Kubernetes", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.