Skip to content

Commit 8586d7d

Browse files
author
wangyazhou
committed
dd
1 parent ff1ee5a commit 8586d7d

File tree

5 files changed

+127
-29
lines changed

5 files changed

+127
-29
lines changed

.obsidian/app.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,12 @@
33
"attachmentFolderPath": "./attachments",
44
"livePreview": true,
55
"showLineNumber": false,
6-
"readableLineLength": false
6+
"readableLineLength": false,
7+
"pdfExportSettings": {
8+
"includeName": true,
9+
"pageSize": "Letter",
10+
"landscape": false,
11+
"margin": "0",
12+
"downscalePercent": 100
13+
}
714
}

.obsidian/workspace.json

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,9 @@
6262
"icon": "lucide-file",
6363
"title": "架构设计"
6464
}
65-
},
66-
{
67-
"id": "6e41c4bae6d0bed8",
68-
"type": "leaf",
69-
"state": {
70-
"type": "markdown",
71-
"state": {
72-
"file": "架构/架构设计.md",
73-
"mode": "source",
74-
"source": false
75-
},
76-
"icon": "lucide-file",
77-
"title": "架构设计"
78-
}
7965
}
8066
],
81-
"currentTab": 4
67+
"currentTab": 3
8268
}
8369
],
8470
"direction": "vertical"
@@ -226,14 +212,15 @@
226212
"obsidian-excalidraw-plugin:新建绘图文件": false
227213
}
228214
},
229-
"active": "6e41c4bae6d0bed8",
215+
"active": "420f6196d6d3217b",
230216
"lastOpenFiles": [
231-
"架构/架构设计模板.md",
232-
"架构/架构设计.md",
233217
"middleware/nginx.md",
218+
"middleware/redis.md",
219+
"k8s/kubernetes.md",
220+
"架构/架构设计.md",
221+
"架构/架构设计模板.md",
234222
"k8s/kubernetes_service.md",
235223
"k8s/kubernetes_network.md",
236-
"k8s/kubernetes.md",
237224
"k8s/kube_prometheus.md",
238225
"go/高并发.md",
239226
"go/go.md",
@@ -244,7 +231,6 @@
244231
"calico/calico.md",
245232
"架构/分布式.md",
246233
"架构/知识学习模板.md",
247-
"middleware/redis.md",
248234
"go/go_package.md",
249235
"go/go_module.md",
250236
"containerd/docker.md",

k8s/harbor.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,14 @@ registry=# select * from harbor_user update harbor_user set salt = '', password
182182
- 再次重启Harbor服务:重新设置密码就行了
183183

184184

185+
## 镜像
185186

187+
### 推镜像
188+
189+
```bash
190+
docker tag ysp/dp-proxy:v1.0.0.123 package.yyhocp.private.com:11036/ysp/dp-proxy:v1.0.0.123
191+
docker push package.yyhocp.private.com:11036/ysp/dp-proxy:v1.0.0.123
192+
```
186193

187194

188195

k8s/kubernetes.md

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
从过去以物理机和虚拟机为主体的开发运维环境,向以容器为核心的基础设施的转变过程,并不是一次温和的改革,而是涵盖了对网络、存储、调度、操作系统、分布式原理等各个方面的容器化理解和改造。这些关于 Linux 内核、分布式系统、网络、存储等方方面面的积累,并不会在Docker 或者 Kubernetes 的文档中交代清楚。可偏偏就是它们,才是真正掌握容器技术体系的精髓所在。
22

33
Kubernetes是一个 **生产级别的容器编排平台和集群管理系统**,不仅能够创建、调度容器,还能够监控、管理服务器。
44

@@ -427,7 +427,7 @@ metadata:
427427
创建成功之后,使用 `kubectl get` `kubectl describe` 来查看ConfigMap的状态
428428

429429
*Secret*
430-
430+
secret里面的数据只是进行了base64加密,如果需要更加安全的方式需要开启Secret加密插件。
431431
Secret中又对对象细分了很多种:
432432

433433
- 访问私有镜像仓库的认证信息
@@ -594,6 +594,64 @@ spec:
594594

595595
> linux中不能使用 - 和 .创建环境变量,创建ConfigMap和Secret的时候需要注意一下。
596596

597+
### Downward API
598+
599+
使用project将多个挂载点整合到同一个目录底下
600+
```yaml
601+
spec:
602+
containers:
603+
- name: main
604+
image: busybox
605+
volumeMounts:
606+
- name: pod-info
607+
mountPath: /etc/podinfo
608+
readOnly: true
609+
volumes:
610+
- name: pod-info
611+
projected: ## 可以将下面所有信息组织放到同一个目录下面
612+
sources:
613+
- downwardAPI:
614+
items:
615+
- path: "name" # 宿主机名字
616+
fieldRef:
617+
fieldPath: metadata.name
618+
- path: "ip"
619+
fieldRef:
620+
fieldPath: status.podIP
621+
- path: "namespace"
622+
fieldRef:
623+
fieldPath: metadata.namespace
624+
- path: "labels"
625+
fieldRef:
626+
fieldPath: metadata.labels
627+
- path: "annotations"
628+
fieldRef:
629+
fieldPath: metadata.annotations
630+
```
631+
632+
633+
以下是您提供的图片内容转化成的文本:
634+
635+
---
636+
637+
### 1. 使用 `fieldRef` 可以声明使用:
638+
- `spec.nodeName` - 宿主机名字
639+
- `status.hostIP` - 宿主机 IP
640+
- `metadata.name` - Pod 的名字
641+
- `metadata.namespace` - Pod 的 Namespace
642+
- `status.podIP` - Pod 的 IP
643+
- `spec.serviceAccountName` - Pod 的 Service Account 的名字
644+
- `metadata.uid` - Pod 的 UID
645+
- `metadata.labels['<KEY>']` - 指定 `<KEY>` 的 `Label` 值
646+
- `metadata.annotations['<KEY>']` - 指定 `<KEY>` 的 `Annotation` 值
647+
- `metadata.labels` - Pod 的所有 Label
648+
- `metadata.annotations` - Pod 的所有 Annotation
649+
650+
### 2. 使用 `resourceFieldRef` 可以声明使用:
651+
- 容器的 CPU limit
652+
- 容器的 CPU request
653+
- 容器的 memory limit
654+
- 容器的 memory request
597655

598656
## 容器编排
599657
[[容器编排]]
@@ -1413,6 +1471,8 @@ Service Mesh 不像 Sidecar 需要和 Service 一起打包一起部署,Service
14131471
![[Pasted image 20250430202140.png]]
14141472

14151473

1474+
k8s中yaml配置所有能用的字段都定义在 `k8s.io/api/core/v1/types.go` 文件中,如果哪个字段不明白具体使用方法可以进行查看。
1475+
14161476

14171477
## 文章
14181478

k8s/kubernetes_security.md

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,50 @@ spec:
123123
Pod才能创建成功。
124124

125125

126-
127-
128-
129-
130-
131-
126+
### Service Account
127+
Service Account 对象的作用,就是 Kubernetes 系统内置的一种“服务账户”,它是Kubernetes 进行权限分配的对象。比如,Service Account A,可以只被允许对Kubernetes API 进行 GET 操作,而 Service Account B,则可以有 Kubernetes API 的所有操作的权限。
128+
129+
像这样的 Service Account 的授权信息和文件,实际上保存在它所绑定的一个特殊的Secret 对象里的。这个特殊的 Secret 对象,就叫作ServiceAccountToken。任何运行在Kubernetes 集群上的应用,都必须使用这个 ServiceAccountToken 里保存的授权信息,也就是 Token,才可以合法地访问 API Server。
130+
131+
为了方便使用,Kubernetes 已经为你提供了一个的默认“服务账户”(default Service Account)。并且,任何一个运行在 Kubernetes 里的 Pod,都可以直接使用这个默认的 Service Account,而无需显示地声明挂载它。
132+
如果你查看一下任意一个运行在 Kubernetes 集群里的 Pod,就会发现,每一个 Pod,都已经自动声明一个类型是 Secret、名为 default-token-xxxx 的 Volume,然后 自动挂载在每个容器的一个固定目录上。
133+
```yaml
134+
- name: kube-api-access-9hqqj
135+
projected:
136+
defaultMode: 420
137+
sources:
138+
- serviceAccountToken:
139+
expirationSeconds: 3607
140+
path: token
141+
- configMap:
142+
items:
143+
- key: ca.crt
144+
path: ca.crt
145+
name: kube-root-ca.crt
146+
- downwardAPI:
147+
items:
148+
- fieldRef:
149+
apiVersion: v1
150+
fieldPath: metadata.namespace
151+
path: namespace
152+
- configMap:
153+
items:
154+
- key: service-ca.crt
155+
path: service-ca.crt
156+
name: openshift-service-ca.crt
157+
status:
158+
conditions:
159+
- lastProbeTime: nul
160+
containerStatuses:
161+
- containerID: cri-o://a24fb6fe5a7e5e0411342f6d5ff7b2e9a0ac503261eab55c27068bb02fa4fe81
162+
...
163+
volumeMounts:
164+
...
165+
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
166+
name: kube-api-access-9hqqj
167+
```
168+
所以说,Kubernetes 其实在每个 Pod 创建的时候,自动在它的spec.volumes 部分添加上了默认 ServiceAccountToken 的定义,然后自动给每个容器加上了对应的 volumeMounts 字段
169+
这样,一旦 Pod 创建完成,容器里的应用就可以直接从这个默认 ServiceAccountToken的挂载目录里访问到授权信息和文件。这个容器内的路径在 Kubernetes 里是固定的,即:`/var/run/secrets/kubernetes.io/serviceaccount`
132170

133171

134172

0 commit comments

Comments
 (0)