当前位置:网站首页>[5 minutes to play lighthouse] take you to the light kubernetes release k3s
[5 minutes to play lighthouse] take you to the light kubernetes release k3s
2022-06-24 06:34:00 【lynnhou】
1. Background Overview
As the most mainstream container orchestration platform at present ,Kubernetes As an infrastructure , Undertake and manage a large number of application services , Compared with the tradition based on VM Image deployment application , It has more 、 Perfect service arrangement and hosting capability . however , Only a few applications need to be deployed or only need to be developed 、 For users of the test environment , build 、 Complete configuration Kubernetes Clustering is a tedious and complicated process , It's easy for beginners to spend a lot of time 、 resources , And the income is limited . lately Lighthouse Launched K3s Apply image , It provides users with out of the box Kubernetes Environmental Science . As lightweight Kubernetes Distribution version ,K3s Passed CNCF Conformance certification , And highly optimized for multiple scenarios , Besides Lighthouse Also integrated in the application image Kubernetes-dashboard, It is convenient for users to cluster through the browser 、 Application management . This article introduces , How to use Lighthouse K3s Deploy 、 Manage your apps .
2. K3s brief introduction
K3s By Rancher Labs Released an open source 、 A very light weight Kubernetes Distribution version . stay Kubernetes On the basis of , Deleted some feature:
- Legacy and non-default features
- Alpha features
- In-tree cloud providers
- In-tree Storage
- Docker (
optional)
Non essential services are deleted at the functional level / function , These include kubernetes Some unstable and informal development version functions , Cut like this , It can not only reduce the probability of failure , It can also reduce the overall kubernetes Resource consumption of the management and control surface . All of the above 5 individual feature, Hence the name K3s. Besides , For application scenarios with limited resources ,K3s Added :
- Simplified installation
- SQLite3 support in addition to etcd
- TLS management
- Automatic Manifest and Helm Chart management
- containerd、CoreDNS、Flannel
K3s It contains what we are familiar with kubernetes Components of , In order to be able to "Simplified installation”, K3S Integrate all components into one binary package (<100MB), In addition, it is installed by default Flannel As CNI plugin, Replace docker Use more lightweight 、 At the bottom containerd, And the use of SQLite3 Replace etcd As the storage of metadata .
Through the above cutting and optimization ,K3s Not only does it eliminate kubernetes The complexity of the installation process 、 Cumbersome steps , It provides users with out of the box deployment experience , It can also be used in the environment with limited resources , Can still provide users with a well functioning kubernetes colony , Keep up with kubernetes Consistent use experience .
3. Environmental preparation
3.1 Get ready Lighthouse Lightweight application servers
We started with Tencent cloud Lighthouse Lightweight app server purchase page , Buy a server . As shown in the figure below .
The specific configuration of the server is as follows :
- regional : Hong Kong, China,
- Mirror image : Apply image K3s
- Example packages :CPU 1 nucleus Memory 2G SSD 50GB Peak bandwidth 6Mbps Monthly traffic 500GB
- Instance name : Input K3s that will do .
Click on “ Buy now ”, After the payment, the server starts to create . When the server state is “ Running ” when , We can use it .
3.2 Firewall configuration
Default Kubernetes-dashboard Monitor in 9090 port , therefore , We need to open the firewall 9090 Port access . stay " Application management " page ,Lighthouse It also provides operation guidance for users :
Click on " determine “, thus , The user can access the access address shown in the figure Kubernetes-dashboard 了 .
3.3 Input dashboard token
Kubernetes-dashboard The login of requires the user to provide token, and token You need to log in to the server to get . Click on... As shown in the following figure “ Sign in ” Button , One click login to the server , Click replication " dashboard-token", Run in server , The output is the required login token, Copy and paste to the previous figure "Enter token" In the input box .
Click on Sign In Button , Login successful !
At this point, the user can use Kubernetes-dashboard Deploy and manage applications .
4. Deploy the application
The following will show how to K3s Upper Department wordpress, visit Kubernetes-dashboard, Click on the top right corner "+"
- Click on the figure below "+"
The following yaml Copy to edit box
apiVersion: v1
kind: Service
metadata:
name: wordpress
labels:
app: wordpress
spec:
ports:
- port: 80
selector:
app: wordpress
tier: frontend
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wp-pv-claim
labels:
app: wordpress
annotations:
volume.beta.kubernetes.io/storage-provisioner: rancher.io/local-path
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: wordpress
labels:
app: wordpress
spec:
selector:
matchLabels:
app: wordpress
tier: frontend
strategy:
type: Recreate
template:
metadata:
labels:
app: wordpress
tier: frontend
spec:
containers:
- image: wordpress:4.8-apache
name: wordpress
env:
- name: WORDPRESS_DB_HOST
value: wordpress-mysql
- name: WORDPRESS_DB_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-pass
key: password
ports:
- containerPort: 80
name: wordpress
volumeMounts:
- name: wordpress-persistent-storage
mountPath: /var/www/html
volumes:
- name: wordpress-persistent-storage
persistentVolumeClaim:
claimName: wp-pv-claim
---
apiVersion: v1
kind: Service
metadata:
name: wordpress-mysql
labels:
app: wordpress
spec:
ports:
- port: 3306
selector:
app: wordpress
tier: mysql
clusterIP: None
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pv-claim
labels:
app: wordpress
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: wordpress-mysql
labels:
app: wordpress
spec:
selector:
matchLabels:
app: wordpress
tier: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: wordpress
tier: mysql
spec:
containers:
- image: mysql:5.6
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-pass
key: password
livenessProbe:
tcpSocket:
port: 3306
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pv-claim
---
apiVersion: v1
kind: Secret
metadata:
name: mysql-pass
data:
password: MWYyZDFlMmU2N2Rm
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: ingress
annotations:
kubernetes.io/ingress.class: "traefik"
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: wordpress
servicePort: 80In this example :
- We created mysql、wordpress Two Deployment, The corresponding Service,mysql The required password adopt secret Provide , Before deployment , Users can modify Secret Fill in the customized password.
- Thanks to the K3s Provided by default local-path-provisioner, Users can create PVC( Default storageclass Has been designated as local-path),local-path-provisioner The corresponding PV. It is important to note that in PVC Of annotations You need to add volume.beta.kubernetes.io/storage-provisioner: rancher.io/local-path.
- K3s The gateway is installed in the application image by default Traefik, It is convenient for users to expose services , For more detailed configuration, see traefik docs.
Click on Upload Start deployment , Wait for the deployment to complete
2. visit http://${ Instance public network IP}/ Get into wordpress Management interface
3. When we need to update the application , You can edit the corresponding... Directly on the panel Deployment
modify resources To configure , Click on "Update" Button ,Kubernetes Will update / upgrade Deployment, What needs to be added is
- Kubernetes The upgrade strategy depends on Deployment designated strategy, Above Deployment designated strategy by recreate, therefore Kubernetes The old version will be closed first , Then start a new version , Users can specify according to their needs strategy, Details refer to Deployment update strategy.
- To configure resources Guarantee limits == requests,Kubernetes The corresponding... Will be set Pod Of Qos Class by Guaranteed, So for key services , Especially when machine resources are scarce , Can guarantee its service quality , Details can be found in Qos Class.
The update is successful !
5. summary
This article shows Lighthouse K3s How to use the application image , And pass wordpress Application deployment example of , Shows how to use Kubernetes-dashboard Deploy 、 Management applications . If you want a quick and easy Kubernetes Environmental Science , For learning Kubernetes, Or to develop 、 test 、 Deploy the application ,Lighthouse application server (K3s Apply image ) Will be very suitable for you ! Give it a try !
边栏推荐
- DHCP server setup
- Double non students, self-taught programming, counter attack Baidu one year after graduation!
- Flexible use of distributed locks to solve the problem of repeated data insertion
- How to apply 5g smart pole to smart highway
- Wordpress5.8 is coming, and the updated website is faster!
- What is Druid
- Project deployment for learning 3D visualization from scratch
- The product layout is strengthened, the transformation of digital intelligence is accelerated, and FAW Toyota has hit 2022million annual sales
- Authoritative recognition! Tencent cloud data security Zhongtai was selected as the 2021 pioneer practice case
- Network Overview
猜你喜欢

ServiceStack. Source code analysis of redis (connection and connection pool)

创客教育给教师发展带来的挑战

【二叉数学习】—— 树的介绍

【二叉树】——二叉树中序遍历

Enter the software test pit!!! Software testing tools commonly used by software testers software recommendations

Technology is a double-edged sword, which needs to be well kept
![[fault announcement] one stored procedure brings down the entire database](/img/7c/e5adda73a077fe4b8f04b59d1e0e1e.jpg)
[fault announcement] one stored procedure brings down the entire database

解读AI机器人产业发展的顶层设计
Fault analysis | using --force to batch import data leads to partial data loss

The product layout is strengthened, the transformation of digital intelligence is accelerated, and FAW Toyota has hit 2022million annual sales
随机推荐
What transmission modes does the IOT data gateway support
Analysis of official template of wechat personnel recruitment management system (II)
Semantic web, semantic web, linked data and knowledge map
Technology is a double-edged sword, which needs to be well kept
Kangaroo cloud: the overall architecture and key technical points of building a real-time computing platform based on Flink
What are the common network protocols
Web automated testing (1): further discussion on UI development history and UI and function automated testing
Continuously evolving cloud native application delivery
MySQL forgets root password cracking root password cracking all user passwords, shell script
Introduction to QWidget attribute table in QT Designer
Oracle case: ohasd crash on AIX
The three-year action plan of the Ministry of industry and information technology has been announced, and the security industry has ushered in major development opportunities!
Innovating the security service mode, deeply convinced that the organization has been equipped with a "continuous online expert group"
Domain name, resolution, SSL certificate product selection
Forbid viewing source code in web page (protect source code)
Nature Neuroscience: challenges and future directions of functional brain tissue characterization
Little transparent apprentice's way to go ashore
解读AI机器人产业发展的顶层设计
Microsoft Security, which frequently swipes the network security circle, gives us some enlightenment this time?
Event delegation