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/03 Report--
This series of articles:
Chapter one: nine analysis will take you to easily complete the date introduction of K8s pod
Chapter 2: nine analysis takes you to easily complete the K8s pod time setting.
Catalogue
1 PodPreset introduction
2 PodPreset enabled
2.1 PodPreset confirmation
2.2 PodPreset enabled
3 PodPreset creation
4 PodPreset verification
1 PodPreset introduction
We learned in the previous section that the docker container will use UTC (International Standard time) by default, because we are CST (Beijing time), so the time in the container will be 8 hours later than Beijing time.
How to modify the container time in batches to keep it in sync with the Beijing time we use? It can be implemented using PodPreset.
PodPreset is a k8s API resource that presets (preset) information such as secrets, configmap, environment variables, volume mounts, etc. when creating a Pod. With PodPreset, instead of displaying the information we need to write for each Pod, we just execute PodPreset API and automatically inject that information into the specified Pod container.
For instructions on PodPreset, click to view.
2 PodPreset enabled
2.1 PodPreset confirmation
The resource type of PodPreset in K8S is settings.k8s.io/v1alpha1, which is not enabled by default. View commands:
Kubectl api-versions
Or:
Kubectl get podpreset
2.2 PodPreset enabled
Edit the / etc/kubernetes/manifests/kube-apiserver.yaml configuration file, add the runtime-config option to the startup parameters, and append PodPreset to the original enable-admission-plugins option.
-- runtime-config=settings.k8s.io/v1alpha1=true / / added
-- enable-admission-plugins=NodeRestriction,PodPreset / / append
It should be noted that:
First: if the cluster is multi-master, then each master needs to be modified.
Second: after modifying the kube-apiserver.yaml file, apiserver will restart automatically, so you need to wait some time.
3 PodPreset creation
Write the resource file pod-preset.yaml:
ApiVersion: settings.k8s.io/v1alpha1
Kind: PodPreset
Metadata:
Name: pod-env-preset
Namespace: default
Spec:
Selector:
MatchLabels:
App: nginx
VolumeMounts:
-mountPath: / etc/localtime
Name: localtime
Volumes:
-name: localtime
HostPath:
Path: / etc/localtime
Create a Podpreset resource:
Kubectl apply-f pod-preset.yaml
View Podpreset resources:
Kubectl get podpreset
4 PodPreset verification
Pay special attention to the scope of PodPreset is namespace. So when creating a pod resource, the namespace should be correct:
Write the resource file pod.yaml:
ApiVersion: v1
Kind: Pod
Metadata:
Name: nginx
Namespace: default
Labels:
App: nginx
Spec:
Containers:
-name: nginx
Image: nginx
Ports:
-containerPort: 80
Create a pod resource:
Kubectl apply-f pod.yaml
After the pod is created successfully, go to the pod container to view the time:
Kubectl exec-it nginx / bin/sh
Since then, pod preset time modification has been easily completed.
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.