In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to complete the K3s Kubeconfig configuration, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
K3s is an open source, very lightweight Kubernetes release released by Rancher Labs earlier this year, perfect for running Kubernetes in a resource-constrained environment. K3s has been highly concerned and recognized by the industry as soon as it was released, and it has nearly 8500 Star on GitHub since its release for half a year.
Originally K3s was just a POC project for local Kubernetes development, but now many enterprise users use it in a production environment.
Official GitRepo:
Https://github.com/rancher/k3s
Official definition: K3s is a fully compliant production Kubernetes release with the following four major changes:
Remove old, non-essential code: K3s does not include any Alpha features that are disabled by default or outdated features, and the original API components are still running in standard deployments. In addition, Rancher removes all non-default license controllers, in- tree cloud providers and storage drivers, but allows users to add any drivers they need.
Integrate running packaging processes: to save RAM,Rancher, merge multiple processes that typically run on the Kubernetes management server into a single process. Rancher also combines the kubelet, kubeproxy, and flannel agent processes running on the worker node into a single process.
Using containerd instead of Docker as the runtime container engine: by replacing Docker,Rancher with containderd, you can significantly reduce runtime footprint and remove features such as libnetwork, swarm, Docker storage drivers, and other plug-ins.
In addition to etcd, SQLite is introduced as an optional data store: Rancher adds SQLite as an optional data store in K3s, providing a lightweight alternative to etcd. This scheme not only takes up less memory, but also greatly simplifies the operation.
In view of the high attention and wide application of K3s, a large number of open source community users have begun to build projects about K3s. This article will share how to use one of the projects, k3sup, to achieve zero to full configuration of K3s Kubeconfig in one minute.
Kubeconfig is fully configured from zero to within K3sup:1 minutes
K3supp: https://github.com/alexellis/k3sup
K3sup is an open source project created by Alex Ellis, which makes it fast and easy to install K3s and generate kubeconfig files. This tool automates the installation of K3s at great speed, updates the SAN address to public IP, downloads the K3s configuration file, and then updates it with VM's public IP address so that you can connect to it using kubectl.
The following steps illustrate this process using an Amazon EC2 example:
Step 1: start the Amazon EC2 instance and have the security group open the port and log in through ssh.
Log in to the Amazon console and click EC2
On EC2 Dashboard, click to start the instance
Select Amazon Linux 2 AMI Mirror
Select the instance type (we will use t2.medium)
Select VPC/Subnet/IAM, etc., and enable automatic allocation of public IP (everything remains default)
Add storage (use default configuration)
Add tags (if necessary)
Configure security groups to allow traffic on different ports (all traffic is enabled in this demo)
Select a key pair and start the instance
Step 2: download the binaries for k3sup
Curl-sLS https://raw.githubusercontent.com/alexellis/k3sup/master/get.sh | sh [ip-172-31-33-136 ec2-user] # curl-sLS https://raw.githubusercontent.com/alexellis/k3sup/master/get.sh | shwhich: no k3sup in (/ sbin:/bin:/usr/sbin:/usr/bin) x86_64Downloading package https://github.com/alexellis/k3sup/releases/download/0.2.0/k3sup as / tmp/k3supDownload complete. Running as root-Attempting to move k3sup to / usr/local/binNew version of k3sup installed to / usr/local/bin
Step 3: copy the ssh key to the'vi / root/.ssh/id_rsa' location in VM, export IP and install K3s using k3sup
[root@ip-172-31-33-136 ec2-user] # * * cd / usr/local/bin** [root @ ip-172-33-136 bin] # * * export IP=54.159.112.255** [root @ ip-172-31-33-136 bin] # *. / k3sup install-- ip $IP-- user ec2-user**Public IP: 54.159.112.255ssh-I / root/.ssh/id_rsa ec2-user@54.159. 112.255ssh: curl-sLS https://get.k3s.io | INSTALL_K3S_EXEC='server-- tls-san 54.159.112.255sh-[INFO] Finding latest release [INFO] Using v0.8.0 as release [INFO] Downloading hash [https://github.com/rancher/k3s/releases/download/v0.8.0/sha256sum-amd64.txt](https://github.com/rancher/k3s/releases/download/v0.8.0/sha256sum-amd64. Txt) [INFO] Downloading binary [https://github.com/rancher/k3s/releases/download/v0.8.0/k3s](https://github.com/rancher/k3s/releases/download/v0.8.0/k3s)[INFO] Verifying binary download [INFO] Installing K3s to / usr/local/bin/k3swhich: no kubectl in (/ usr/local/bin:/usr/bin) [INFO] Creating / usr/local/bin/kubectl symlink to k3swhich: no crictl in (/ usr) / local/bin:/usr/bin) [INFO] Creating / usr/local/bin/crictl symlink to k3swhich: no ctr in (/ usr/local/bin:/usr/bin) [INFO] Creating / usr/local/bin/ctr symlink to K3s [INFO] Creating killall script / usr/local/bin/k3s-killall.sh [INFO] Creating uninstall script / usr/local/bin/k3s-uninstall.sh [INFO] env: Creating environment file / etc/systemd/system/k3s.service.env [INFO ] systemd: Creating service file / etc/systemd/system/k3s.service [INFO] systemd: Enabling K3s unitCreated symlink from / etc/systemd/system/multi-user.target.wants/k3s.service to / etc/systemd/system/k3s.service. [INFO] systemd: Starting k3sResult: [INFO] Finding latest release [INFO] Using v0.8.0 as release [INFO] Downloading hash [https://github.com/rancher/k3s/releases/download/v0.8.0/sha256sum-amd64. Txt] (https://github.com/rancher/k3s/releases/download/v0.8.0/sha256sum-amd64.txt)[INFO] Downloading binary [https://github.com/rancher/k3s/releases/download/v0.8.0/k3s](https://github.com/rancher/k3s/releases/download/v0.8.0/k3s)[INFO] Verifying binary download [INFO] Installing K3s to / usr/local/bin/k3s [INFO] Creating / usr/local/bin / kubectl symlink to k3s [INFO] Creating / usr/local/bin/crictl symlink to k3s [INFO] Creating / usr/local/bin/ctr symlink to k3s [INFO] Creating killall script / usr/local/bin/k3s-killall.sh [INFO] Creating uninstall script / usr/local/bin/k3s-uninstall.sh [INFO] env: Creating environment file / etc/systemd/system/k3s.service.env [INFO] systemd: Creating service file / etc/systemd/system/k3s.service [INFO] systemd : Enabling K3s unit [INFO] systemd: Starting k3swhich: no kubectl in (/ usr/local/bin:/usr/bin) which: no crictl in (/ usr/local/bin:/usr/bin) which: no ctr in (/ usr/local/bin:/usr/bin) Created symlink from / etc/systemd/system/multi-user.target.wants/k3s.service to / etc/systemd/system/k3s.service.ssh: sudo cat / etc/rancher/k3s/k3s.yamlSaving file to: / usr/local/bin/kubeconfig
It will create a kubeconfig file and save it in the directory where you run the command.
Step 4: export KUBECONFIG
[root@ip-172-31-33-136 bin] # * * export KUBECONFIG= `pwd` / kubeconfig**
Step 5: start playing K3s
[root@ip-172-31-33-136bin] # *. / kubectl get nodes**NAME STATUS ROLES AGE VERSIONip-172-31-33-136.ec2.internal Ready master 24s v1.14.5-k3s.1 [root@ip-172-31-33-136bin] # *. / kubectl get pods-n kube-system**NAME READY STATUS RESTARTS AGEcoredns-b7464766c-ngf46 1 Running 0 4m3shelm-install-traefik-x6wfj 0 3m49s 1 Completed 0 4m3ssvclb-traefik-65gw9 2 4m3ssvclb-traefik-65gw9 2 Running 0 3m49straefik-56688c4464-5rdss 1 Running 0 3m49s
Run a simple service:
# Create a Deployment**./kubectl run nginx-- image=nginx**# Create Service [root @ ip-172-31-33-136 bin] # *. / kubectl expose deployment nginx-- port=80-- target-port=80**service/nginx exposed [root@ip-172-31-33-136 bin] # *. / kubectl get svc**NAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGEkubernetes ClusterIP 10.43.0.1 443/TCP 45mnginx ClusterIP 10.43.99.179 80/TCP 5s [root @ ip-172-31-33-136 bin] # * * curl 10.43.99.179**Welcome to nginxbody {width: 35em Margin: 0 auto;font-family: Tahoma, Verdana, Arial, sans-serif;} Welcome to nginx!
If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.
For online documentation and support please refer tonginx.org.Commercial support is available atnginx.com.
Thank you for using nginx.
Add two nodes: can you connect the node to the primary node without logging in to the node? Yes, k3sup can do that.
After getting the K3s settings on VM, you can easily add nodes to the cluster:
# AGENT_IP is the IP of the VM that you want to add to the cluster that has K3s running**export AGENT_IP=54.196.113.156**#SERVER_IP is the IP of the server where K3 is installed export SERVER_IP=54.159.112.255**export USER=ec2-user** [root@ip-172-31-33-136bin] # *. / k3sup join-- ip $AGENT_IP-- server-ip $SERVER_IP-- user ec2-user**Server IP: 54.159.112 .255ssh-I / root/.ssh/id_rsa ec2-user@54.159.112.255ssh: sudo cat / var/lib/rancher/k3s/server/node-tokenK1077d707d0868b652aca7adfc21b5f34a1f0357e71b216bf8b3c94a559cd4f93a6::node:014c8ed3f6574d27db73b9c8bf67f617ssh: curl-sfL https://get.k3s.io/ | K3SystURL = "https://54.159.112.255:6443" K3SystToken =" K1077d707d0868b652aca7adfc21b5f34a1f0357e71b216bf8b3c94a559cd4f93a6::node:014c8ed3f6574d27db73b9c8bf67f617 "sh-[INFO] Finding latest release [INFO] Using v0.8.0 as release [INFO] Downloading hash [https: / / github.com/rancher/k3s/releases/download/v0.8.0/sha256sum-amd64.txt] (https://github.com/rancher/k3s/releases/download/v0.8.0/sha256sum-amd64.txt)[INFO] Downloading binary [https://github.com/rancher/k3s/releases/download/v0.8.0/k3s](https://github.com/rancher/k3s/releases/download/v0.8.0/k3s)[INFO] Verifying binary download [INFO] ] Installing K3s to / usr/local/bin/k3swhich: no kubectl in (/ usr/local/bin:/usr/bin) [INFO] Creating / usr/local/bin/kubectl symlink to k3swhich: no crictl in (/ usr/local/bin:/usr/bin) [INFO] Creating / usr/local/bin/crictl symlink to k3swhich: no ctr in (/ usr/local/bin:/usr/bin) [INFO] Creating / usr/local/bin/ctr symlink to K3s [INFO] Creating killall script / Usr/local/bin/k3s-killall.sh [INFO] Creating uninstall script / usr/local/bin/k3s-agent-uninstall.sh [INFO] env: Creating environment file / etc/systemd/system/k3s-agent.service.env [INFO] systemd: Creating service file / etc/systemd/system/k3s-agent.service [INFO] systemd: Enabling k3s-agent unitCreated symlink from / etc/systemd/system/multi-user.target.wants/k3s-agent.service to / etc/systemd/system/k3s-agent .service. [INFO] systemd: Starting k3s-agentLogs: which: no kubectl in (/ usr/local/bin:/usr/bin) which: no crictl in (/ usr/local/bin:/usr/bin) which: no ctr in (/ usr/local/bin:/usr/bin) Created symlink from / etc/systemd/system/multi-user.target.wants/k3s-agent.service to / etc/systemd/system/k3s-agent.service.Output: [INFO] Finding latest release [INFO] Using V0.8.0 as release [INFO] Downloading hash [https://github.com/rancher/k3s/releases/download/v0.8.0/sha256sum-amd64.txt](https://github.com/rancher/k3s/releases/download/v0.8.0/sha256sum-amd64.txt)[INFO] Downloading binary [https://github.com/rancher/k3s/releases/download/v0.8.0/k3s](https://github.com/rancher/k3s/releases/download/v0] .8.0 / K3s) [INFO] Verifying binary download [INFO] Installing K3s to / usr/local/bin/k3s [INFO] Creating / usr/local/bin/kubectl symlink to K3s [INFO] Creating / usr/local/bin/crictl symlink to K3s [INFO] Creating / usr/local/bin/ctr symlink to K3s [INFO] Creating killall script / usr/local/bin/k3s-killall.sh [INFO] Creating uninstall script / usr/local/bin/k3s-agent-uninstall.sh [INFO] Env: Creating environment file / etc/systemd/system/k3s-agent.service.env [INFO] systemd: Creating service file / etc/systemd/system/k3s-agent.service [INFO] systemd: Enabling k3s-agent unit [INFO] systemd: Starting k3s-agent [root@ip-172-31-33-136bin] # *. / kubectl get nodes**NAME STATUS ROLES AGE VERSIONip-172-31-33-136.ec2.internal Ready master 19m v1.14.5-k3s.1ip-172-31-37-118.ec2.internal Ready worker 11s v1.14.5-k3s.1 Thank you for reading this article carefully I hope the article "how to complete the K3s Kubeconfig configuration" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you 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.