In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
In the last article, we successfully ran K3s on mac. So, today we go one step further and deploy the Jenkins pipeline above to see how K3s is actually being used.
Similar to yesterday's steps, but the memory settings for VM are different:
1. Prepare Multipass VM and install K3s
Let's create a VM of 2GB memory and 50GB disk
Multipass launch-- name K3s-- mem 2G-- disk 50G
The method of installing K3s is the same, but you need to check the running scripts all the time.
Multipass exec K3s-- sh-c "curl-sfL https://get.k3s.io | sh -"
Copy the kubeconfig file to the host
Multipass copy-files k3s:/etc/rancher/k3s/k3s.yaml.
Use the command: multipass info K3s, list the information of K3s to get the IP address, replace the server address from https://localhost:6443 to https://192.168.64.5:6443, export kubeconfig, and confirm that the node is working properly.
Now we are ready to develop the environment of K3s. We do not need to enter the VM because the kubectl command line of the host is sufficient.
2. Dynamic storage class
We need to provide dynamic storage in order to do some practical work. We use local volume provisioner (https://github.com/rancher/local-path-provisioner) to do this. Download the yaml file and check it before using it.
Curl-LO https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
Apply it and modify this type of storage class to default storage.
Kubectl apply-f local-path-storage.yamlkubectl patch storageclass local-path- p'{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "true"}}'
Now we are ready for dynamic storage classes.
3. Deploy Jenkins Helm Chart
K3s implements built-in support for HelmChart by providing CRD. We don't need to deploy tiller components, or even the helm command.
Let's create a HelmChart CRD based on the following code
ApiVersion: k3s.cattle.io/v1kind: HelmChartmetadata: name: jenkins namespace: kube-systemspec: chart: stable/jenkins targetNamespace: jenkins valuesContent: |-Master: AdminUser: {{.adminUser}} AdminPassword: {{.adminPassword}} rbac: install: true
Note that the namespaces in the metadata are used for HelmChart objects. K3s monitors the CRD object in kube-sysytem, and if any new HelmChart object is created, it launches the Helm installation job.
Chart defines which repo and Helm Chart to deploy. The Jenkins should be in the target namespace. Instead of using the "set" keyword in the readme example, I use valuesContent, where I can apply the same format as Chart's value.yaml file.
Save the file as jenkins.yaml without changing the Jenkins. Create the target namespace and apply it as a Kubernetes object yaml file.
Kubectl create ns jenkinskubectl apply-f jenkins.yaml
Start monitoring Helm installation job
Kubectl-n kube-system get podsNAME READY STATUS RESTARTS AGEcoredns-7748f7f6df-g6rgw 1 kube-system get podsNAME READY STATUS RESTARTS AGEcoredns-7748f7f6df-g6rgw 1 Running 0 138mhelm-install-jenkins-txxjn 0 138mtraefik-5cc8776646-nfclx 1 Completed 0 111mhelm-install-traefik-bnc5x 0 138msvclb-traefik-b65f58f65-rxllp 1 Completed 0 138msvclb-traefik-b65f58f65-rxllp 2 Running 0 138mtraefik-5cc8776646-nfclx 1/1 Running 0 138m
Verify that PVC is bound
Kubectl-n jenkins get pvcNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGEjenkins Bound pvc-18988281-4d45-11e9-b75c-5ef9efd9374c 8Gi RWO local-path 113m
Also verify that pod is running.
Kubectl-n jenkins get podsNAME READY STATUS RESTARTS AGEjenkins-6b6f58bc8d-hbf4r 1 113msvclb-jenkins-74fdf6b9f4-zxnwz 1 Running 0 113msvclb-jenkins-74fdf6b9f4-zxnwz 1 Running 0 113m
4. Visit Jenkins
Looking for service port
Kubectl-n jenkins get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGEjenkins LoadBalancer 10.43.75.62 192.168.64.5 8080:30254/TCP 115mjenkins-agent ClusterIP 10.43.239.13 50000/TCP 115m
Now, we can use http://192.168.64.5:8080. Access Jenkins as follows:
If you want to know more about the skills of using K3s, welcome to join the offline workshop of K3s held in Shenzhen on October 26th. The senior architect of Rancher Labs will introduce the functions, features and usage scenarios of K3s for you in detail, and conduct on-site demo, and will also take you to build a K3s cluster with your own notebook. Click here to sign up!
Welcome to add a small assistant (× ×: × ×) to join the official technical group to learn more about Kubernetes usage strategies.
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.