1.日志 kubectl logs
监控 foobar Pod 的日志,提取 pod 相应的行’error’写入到/logs 文件中
Set configuration context $ kubectl config use-context k8s Monitor the logs of Pod foobar and
Extract log lines corresponding to error file-not-found
Write them to /opt/KULM00201/foobar
kubectl logs foobar | grep file-not-found > /logs
2.输出排序 --sort-by=.metadata.name
使用 name 排序列出所有的 PV,把输出内容存储到/opt/文件中 使用 kubectl own 对输出进行排序,并且不再进一步操作它
List all PVs sorted by name saving the full kubectl output to /opt/KUCC0010/my_volumes . Use kubectl’s own functionally for sorting the output, and do not manipulate it any further.
kubectl get pv --all-namespace --sort-by=.metadata.name > /opt/
3.ds部署
确保在 kubectl 集群的每个节点上运行一个 Nginx Pod。其中 Nginx Pod 必须使用 Nginx 镜像。不要覆盖当前环境中的任何 traints。 使用 Daemonset 来完成这个任务,Daemonset 的名字使用 ds。
Ensure a single instance of Pod nginx is running on each node of the kubernetes cluster where nginx also represents the image name which has to be used. Do no override any taints currently in place.
Use Daemonsets to complete this task and use ds.kusc00201 as Daemonset name
题目对应文档:https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/
删除tolerations字段,复制到image: gcr.io/fluentd-elasticsearch/fluentd:v2.5.1这里即可,再按题意更改yaml文件。
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: ds
namespace: kube-system
labels:
k8s-app: fluentd-logging
spec:
selector:
matchLabels:
name: fluentd-elasticsearch
template:
metadata:
labels:
name: fluentd-elasticsearch
spec:
containers:
- name: fluentd-elasticsearch
image: nginx
4.initContainers
添加一个 initcontainer 到 lum(/etc/data)这个 initcontainer 应该创建一个名为/workdir/calm.txt 的空文件,如果/workdir/calm.txt 没有被检测到,这个 Pod 应该退出
Add an init container to lumpy--koala (Which has been defined in spec file /opt/kucc00100/pod-spec-KUCC00100.yaml)
The init container should create an empty file named /workdir/calm.txt
If /workdir/calm.txt is not detected, the Pod should exit
Once the spec file has been updated with the init container definition, the Pod shou
ld be created.
-
- 题目中yaml文件已经给出,只需要增加initcontainers部分,以及emptyDir: {} 即可
init文档位置:https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
在最后加上
initContainers: - name: init-poda image: busybox command: ['sh','-c','touch /workdir/clam.txt'] volumeMounts: - name: workdir mountPath: "/workdir" - 题目中yaml文件已经给出,只需要增加initcontainers部分,以及emptyDir: {} 即可
5.多容器
创建一个名为 kucc 的 Pod,其中内部运行着 nginx+redis+memcached+consul 4 个容器
Create a pod named kucc4 with a single container for each of the following images running inside (there may be between 1 and 4 images specified): nginx + redis + memcached + consul
参考链接:
https://v1-14.docs.kubernetes.io/docs/concepts/workloads/pods/pod-overview/
apiVersion: v1
kind: Pod
metadata:
name: kucc
spec:
containers:
- name: nginx
image: nginx
- name: redis
image: redis
- name: memcached
image: memcached
- name: consul
image: consul
6.nodeSelector
创建 Pod,名字为 nginx,镜像为 nginx,部署到 label disk=ssd的node上
Schedule a P

本文深入探讨Kubernetes的高级操作,包括日志监控、资源调度、多容器部署、存储卷管理、服务发现、证书管理及故障排查等核心技能,旨在帮助读者掌握Kubernetes的实战应用。
最低0.47元/天 解锁文章
1764

被折叠的 条评论
为什么被折叠?



