From db9ac4e729ad7255cd1b9d16e532668bd0106aaa Mon Sep 17 00:00:00 2001 From: LuoXingchen <42908923+LuoXingchen935@users.noreply.github.com> Date: Fri, 31 Jul 2026 23:19:23 +0800 Subject: [PATCH] feat(k8s-memo): add i18n support for memo content (#546) --- src/tools/k8s-memo/k8s-memo.content.zh.md | 183 ++++++++++++++++++++++ src/tools/k8s-memo/k8s-memo.vue | 37 ++++- 2 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 src/tools/k8s-memo/k8s-memo.content.zh.md diff --git a/src/tools/k8s-memo/k8s-memo.content.zh.md b/src/tools/k8s-memo/k8s-memo.content.zh.md new file mode 100644 index 00000000..acc63296 --- /dev/null +++ b/src/tools/k8s-memo/k8s-memo.content.zh.md @@ -0,0 +1,183 @@ +# Kubernetes + +* PDF:https://sematext.com/kubernetes-cheat-sheet/ +* 官网:https://kubernetes.io/ +* 文档:https://kubernetes.io/docs/home + +## 客户端配置 + +* 在 bash 中设置自动补全;需先安装 bash-completion 包 +``` +source <(kubectl completion bash) +``` + +* 查看 Kubernetes 配置 +``` +kubectl config view +``` + +* 通过 jsonpath 查看特定配置项 +``` +kubectl config view -o jsonpath='{.users[?(@.name == "k8s")].user.password}' +``` + +* 为 `foo.kuberntes.com` 设置凭据 +``` +kubectl config set-credentials kubeuser/foo.kubernetes.com --username=kubeuser --password=kubepassword +``` + +* 设置当前命名空间 +``` +kubectl config set-context --current --namespace=namespace_name +``` + +## 查看、查找资源 + +* 列出命名空间中的所有服务 +``` +kubectl get services +``` + +* 以宽格式列出所有命名空间中的所有 Pod +``` +kubectl get pods -o wide --all-namespaces +``` + +* 以 json(或 yaml)格式列出所有 Pod +``` +kubectl get pods -o json +``` + +* 查看资源详情(node、pod、svc) +``` +kubectl describe nodes my-node +``` + +* 按名称列出服务 +``` +kubectl get services --sort-by=.metadata.name +``` + +* 按重启次数列出 Pod +``` +kubectl get pods --sort-by='.status.containerStatuses[0].restartCount' +``` + +* 对 frontend-v1 进行滚动更新 +``` +kubectl rolling-update frontend-v1 -f frontend-v2.json +``` + +* 将名为 'foo' 的副本集扩缩容至 3 个 +``` +kubectl scale --replicas=3 rs/foo +``` + +* 将 "foo.yaml" 中指定的资源扩缩容至 3 个 +``` +kubectl scale --replicas=3 -f foo.yaml +``` + +* 在每个 Pod / 副本中执行命令 +``` +for i in 0 1; do kubectl exec foo-$i -- sh -c 'echo $(hostname) > /usr/share/nginx/html/index.html'; done +``` + +## 管理资源 + +* 获取 Pod 或服务的文档说明 +``` +kubectl explain pods,svc +``` + +* 创建资源(如 Pod、服务或守护进程集) +``` +kubectl create -f ./my-manifest.yaml +``` + +* 对资源应用配置 +``` +kubectl apply -f ./my-manifest.yaml +``` + +* 启动单个 Nginx 实例 +``` +kubectl run nginx --image=nginx +``` + +* 创建包含多个键的 Secret +``` +cat < +import { ref, watch } from 'vue'; +import { useI18n } from 'vue-i18n'; import { useThemeVars } from 'naive-ui'; -import Memo from './k8s-memo.content.md'; +import type { Component } from 'vue'; const themeVars = useThemeVars(); +const { locale } = useI18n(); + +const memoImports = import.meta.glob('./k8s-memo.content*.md'); +const memoComponent = ref(null); + +async function loadMemo(currentLocale = locale.value) { + const memoKey = `./k8s-memo.content.${currentLocale}.md`; + const loader = memoImports[memoKey] ?? memoImports['./k8s-memo.content.md']; + + if (!loader) { + memoComponent.value = null; + return; + } + + const module = (await loader()) as { default?: Component }; + memoComponent.value = module.default ?? module; +} + +watch(locale, () => { + loadMemo(); +}, { immediate: true }); @@ -19,4 +42,14 @@ const themeVars = useThemeVars(); border-radius: 4px; overflow: auto; } +::v-deep(table) { + border-collapse: collapse; +} +::v-deep(table), ::v-deep(td), ::v-deep(th) { + border: 1px solid v-bind('themeVars.textColor1'); + padding: 5px; +} +::v-deep(a) { + color: v-bind('themeVars.textColor1'); +}