volume-mount
This commit is contained in:
@ -1,7 +1,13 @@
|
||||
<template>
|
||||
<div :style="$isDev ? 'background-color: grey;' : ''">
|
||||
<p>
|
||||
<Qq></Qq> 群号: 808894550 <span style="color: red; font-weight: 500;">在线答疑</span>,也可以扫描本文末尾的二维码加群
|
||||
<div :style="$isDev ? 'background-color: #grey;' : ''">
|
||||
<p style="background-color: #f3f5f7;padding: 10px 5px 5px 5px;">
|
||||
<Qq></Qq>
|
||||
群号: 808894550
|
||||
<span style="color: red; font-weight: 500;">在线答疑</span>,
|
||||
初学者可选择在线课程,语言更通俗:
|
||||
<span @click="$sendGaEvent('极客时间', '极客时间', '极客时间:' + $page.path)">
|
||||
<a target="_blank" href="https://time.geekbang.org/column/intro/100015201?code=MH1Wu456g0ZsrKtQI7QidivKV2hVvzerAUxDz5pOuQs%3D">深入剖析Kubernetes</a>
|
||||
</span>
|
||||
</p>
|
||||
<slot></slot>
|
||||
<!-- <div class="adsense-page-top">
|
||||
|
||||
@ -202,6 +202,7 @@ module.exports = {
|
||||
// ['install-k8s-upgrade', '升级Kubernetes集群'],
|
||||
'upgrade-k8s/1.15.x-1.15.4',
|
||||
'upgrade-k8s/1.15.x-1.16.x',
|
||||
'upgrade-k8s/calico-3.8-3.9',
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -371,6 +372,7 @@ module.exports = {
|
||||
collapsable: true,
|
||||
children: [
|
||||
'k8s-intermediate/persistent/volume',
|
||||
'k8s-intermediate/persistent/volume-mount-point.html',
|
||||
'k8s-intermediate/persistent/pv',
|
||||
'k8s-intermediate/persistent/storage-class',
|
||||
'k8s-intermediate/persistent/nfs',
|
||||
@ -462,6 +464,13 @@ module.exports = {
|
||||
'k8s-advanced/schedule/framework',
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '策略',
|
||||
collapsable: true,
|
||||
children: [
|
||||
'k8s-advanced/policy/lr',
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@ -31,6 +31,6 @@ cp -i /etc/kubernetes/admin.conf /root/.kube/config
|
||||
# 安装 calico 网络插件
|
||||
# 参考文档 https://docs.projectcalico.org/v3.9/getting-started/kubernetes/
|
||||
rm -f calico.yaml
|
||||
wget https://docs.projectcalico.org/v3.9/manifests/calico.yaml
|
||||
wget https://docs.projectcalico.org/v3.9/manifests/calico.yaml --no-check-certificate
|
||||
sed -i "s#192\.168\.0\.0/16#${POD_SUBNET}#" calico.yaml
|
||||
kubectl apply -f calico.yaml
|
||||
|
||||
@ -19,7 +19,7 @@ Kuboard 是一款基于 Kubernetes 的微服务管理界面。目的是帮助用
|
||||
|
||||
## Kubernetes安装文档
|
||||
|
||||
* <a href="https://kuboard.cn/install/install-k8s.html">Kubernetes (K8S)v1.16.1 安装文档</a>
|
||||
* <a href="https://kuboard.cn/install/install-k8s.html">Kubernetes (K8S)v1.16.2 安装文档</a>
|
||||
* 每天超过200名网友参考此文档完成Kubernetes安装
|
||||
* QQ群在线答疑
|
||||
* <a href="https://kuboard.cn/install/install-kubernetes.html">Kubernetes 高可用安装文档</a>
|
||||
|
||||
@ -156,7 +156,7 @@ lscpu
|
||||
| ----------- | --------------------------------------- | ----------------------------------- |
|
||||
| 7.7 | <span style="font-size: 24px;">😄</span> | 已验证 |
|
||||
| 7.6 | <span style="font-size: 24px;">😄</span> | 已验证 |
|
||||
| 7.5 | <span style="font-size: 24px;">😄</span> | 已验证 |
|
||||
| 7.5 | <span style="font-size: 24px;">🤔</span> | 已证实会出现 kubelet 无法启动的问题 |
|
||||
| 7.4 | <span style="font-size: 24px;">🤔</span> | 待验证 |
|
||||
| 7.3 | <span style="font-size: 24px;">🤔</span> | 待验证 |
|
||||
| 7.2 | <span style="font-size: 24px;">😞</span> | 已证实会出现 kubelet 无法启动的问题 |
|
||||
|
||||
72
install/upgrade-k8s/calico-3.8-3.9.md
Normal file
72
install/upgrade-k8s/calico-3.8-3.9.md
Normal file
@ -0,0 +1,72 @@
|
||||
---
|
||||
# vssueId: 107
|
||||
description: Kubernetes升级1.16.x。本文描述了如何从 Kubernetes 网络插件 calico 3.8.x 升级到 3.9。执行命令 kubectl describe deployment calico-kube-controllers -n kube-system 确认当前 calico 版本
|
||||
meta:
|
||||
- name: keywords
|
||||
content: Kubernetes升级,K8S升级,升级calico
|
||||
---
|
||||
|
||||
# 升级网络插件calico
|
||||
|
||||
<AdSenseTitle/>
|
||||
|
||||
::: danger
|
||||
升级 calico 时,集群内部网络会不可用,请选择合适的时间升级
|
||||
:::
|
||||
|
||||
## 确认当前版本
|
||||
|
||||
执行以下命令确认当前 calico 版本
|
||||
|
||||
``` sh
|
||||
kubectl describe deployment calico-kube-controllers -n kube-system
|
||||
```
|
||||
|
||||
输出结果如下所示:
|
||||
|
||||
``` yaml {18}
|
||||
Name: calico-kube-controllers
|
||||
Namespace: kube-system
|
||||
CreationTimestamp: Tue, 20 Aug 2019 06:38:17 +0800
|
||||
Labels: k8s-app=calico-kube-controllers
|
||||
Annotations: deployment.kubernetes.io/revision: 1
|
||||
kubectl.kubernetes.io/last-applied-configuration:
|
||||
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"k8s-app":"calico-kube-controllers"},"name":"calico-kub...
|
||||
Selector: k8s-app=calico-kube-controllers
|
||||
Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable
|
||||
StrategyType: Recreate
|
||||
MinReadySeconds: 0
|
||||
Pod Template:
|
||||
Labels: k8s-app=calico-kube-controllers
|
||||
Annotations: scheduler.alpha.kubernetes.io/critical-pod:
|
||||
Service Account: calico-kube-controllers
|
||||
Containers:
|
||||
calico-kube-controllers:
|
||||
Image: calico/kube-controllers:v3.8.2
|
||||
Port: <none>
|
||||
Host Port: <none>
|
||||
Readiness: exec [/usr/bin/check-status -r] delay=0s timeout=1s period=10s #success=1 #failure=3
|
||||
Environment:
|
||||
ENABLED_CONTROLLERS: node
|
||||
DATASTORE_TYPE: kubernetes
|
||||
Mounts: <none>
|
||||
Volumes: <none>
|
||||
```
|
||||
|
||||
## 清理已有安装
|
||||
|
||||
如上所示,calico镜像是 v3.8.2,要清理已有 calico 安装,执行命令:
|
||||
|
||||
``` sh
|
||||
# 如果版本号是 v3.8.2 或者 v3.8.x,则删除命令如下
|
||||
# calico.yaml 的URL中,不带版本号的最后一位
|
||||
kubectl delete -f https://docs.projectcalico.org/v3.8/manifests/calico.yaml --no-check-certificate
|
||||
```
|
||||
|
||||
## 安装新版本
|
||||
|
||||
执行以下命令,安装 calico 3.9:
|
||||
|
||||
``` sh
|
||||
kubectl delete -f https://docs.projectcalico.org/v3.9/manifests/calico.yaml --no-check-certificate
|
||||
```
|
||||
@ -13,11 +13,37 @@ meta:
|
||||
|
||||
<AdSenseTitle>
|
||||
|
||||
默认情况下,容器在 Kubernetes 集群上运行时,不受 [计算资源](/learning/k8s-intermediate/config/computing-resource.html) 的限制。使用 [Resource quota](./rq.html),集群管理员可以针对名称空间限定资源的使用情况。在名称空间内部,一个 Pod(或容器)的资源消耗不受限制。此时的顾虑在于,可能有一个 Pod(或容器)独占了名称空间的大部分资源。Limit Range 是一种用来限定名称空间内 Pod(或容器)可以消耗资源数量的策略。
|
||||
默认情况下,容器在 Kubernetes 集群上运行时,不受 [计算资源](/learning/k8s-intermediate/config/computing-resource.html) 的限制。使用 [Resource quota](./rq.html),集群管理员可以针对名称空间限定资源的使用情况。在名称空间内部,一个 Pod(或容器)的资源消耗不受限制。此时的顾虑在于,可能有一个 Pod(或容器)独占了名称空间的大部分资源。Limit Range 是一种用来限定名称空间内 Pod(或容器)可以消耗资源数量的策略(Policy)。
|
||||
|
||||
[[TOC]]
|
||||
|
||||
KUbernetes `LimitRange` 对象可以:
|
||||
* 限制名称空间中每个 Pod 或容器的最小最大计算资源
|
||||
* 限制名称空间中每个 PersistentVolumeClaim 可使用的最小最大存储空间
|
||||
* 限制名称空间中计算资源请求request、限定limit之间的比例
|
||||
* 设置名称空间中默认的计算资源的 request/limit,并在运行时自动注入到容器中
|
||||
|
||||
</AdSenseTitle>
|
||||
|
||||
## 启用 Limit Range
|
||||
|
||||
正在撰写 ...
|
||||
执行命令 `kubectl api-resources` 可查看您的集群是否支持 Limit Range,输出结果如下所示:
|
||||
``` {7}
|
||||
NAME SHORTNAMES APIGROUP NAMESPACED KIND
|
||||
bindings true Binding
|
||||
componentstatuses cs false ComponentStatus
|
||||
configmaps cm true ConfigMap
|
||||
endpoints ep true Endpoints
|
||||
events ev true Event
|
||||
limitranges limits true LimitRange
|
||||
namespaces ns false Namespace
|
||||
nodes no false Node
|
||||
persistentvolumeclaims pvc true PersistentVolumeClaim
|
||||
persistentvolumes pv false PersistentVolume
|
||||
pods po true Pod
|
||||
podtemplates true PodTemplate
|
||||
```
|
||||
|
||||
通常 LimitRange 是默认启用的。
|
||||
|
||||
<!-- FIXME 如何启用 LimitRange -->
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
---
|
||||
vssueId: 140
|
||||
layout: LearningLayout
|
||||
description: Kubernetes教程_本文介绍Kubernetes中Volume(数据卷)的挂载以及挂载传播MountPropagation的概念
|
||||
meta:
|
||||
@ -8,14 +9,96 @@ meta:
|
||||
|
||||
# 数据卷-挂载
|
||||
|
||||
|
||||
<AdSenseTitle/>
|
||||
|
||||
参考文档: Kubernetes 官网文档 [Volumes](https://kubernetes.io/docs/concepts/storage/volumes/)
|
||||
> 参考文档: Kubernetes 官网文档 [Volumes](https://kubernetes.io/docs/concepts/storage/volumes/)
|
||||
|
||||
挂载是指将定义在 Pod 中的数据卷关联到容器,同一个 Pod 中的同一个数据卷可以被挂载到该 Pod 中的多个容器上。
|
||||
|
||||
## 数据卷内子路径
|
||||
|
||||
有时候我们需要在同一个 Pod 的不同容器间共享数据卷。使用 `volumeMounts.subPath` 属性,可以使容器在挂载数据卷时指向数据卷内部的一个子路径,而不是直接指向数据卷的根路径。
|
||||
|
||||
下面的例子中,一个 LAMP(Linux Apache Mysql PHP)应用的 Pod 使用了一个共享数据卷,HTML 内容映射到数据卷的 `html` 目录,数据库的内容映射到了 `mysql` 目录:
|
||||
|
||||
``` yaml {15,22}
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: my-lamp-site
|
||||
spec:
|
||||
containers:
|
||||
- name: mysql
|
||||
image: mysql
|
||||
env:
|
||||
- name: MYSQL_ROOT_PASSWORD
|
||||
value: "rootpasswd"
|
||||
volumeMounts:
|
||||
- mountPath: /var/lib/mysql
|
||||
name: site-data
|
||||
subPath: mysql
|
||||
readOnly: false
|
||||
- name: php
|
||||
image: php:7.0-apache
|
||||
volumeMounts:
|
||||
- mountPath: /var/www/html
|
||||
name: site-data
|
||||
subPath: html
|
||||
readOnly: false
|
||||
volumes:
|
||||
- name: site-data
|
||||
persistentVolumeClaim:
|
||||
claimName: my-lamp-site-data
|
||||
```
|
||||
|
||||
### 通过环境变量指定数据卷内子路径
|
||||
|
||||
**FEATURE STATE:** `Kubernetes v1.15` <Badge type="warning">beta</Badge> <Badge type="error">Kuboard暂不支持</Badge>
|
||||
|
||||
使用 `volumeMounts.subPathExpr` 字段,可以通过容器的环境变量指定容器内路径。使用此特性时,必须启用 `VolumeSubpathEnvExpansion` [feature gate](https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/) (自 Kubernetes v1.15 开始,是默认启用的。)
|
||||
|
||||
同一个 volumeMounts 中 `subPath` 字段和 `subPathExpr` 字段不能同时使用。
|
||||
|
||||
如下面的例子,该 Pod 使用 `subPathExpr` 在 hostPath 数据卷 `/var/log/pods` 中创建了一个目录 `pod1`(该参数来自于Pod的名字)。此时,宿主机目录 `/var/log/pods/pod1` 挂载到了容器的 `/logs` 路径:
|
||||
|
||||
``` yaml {9,19}
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: pod1
|
||||
spec:
|
||||
containers:
|
||||
- name: container1
|
||||
env:
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
image: busybox
|
||||
command: [ "sh", "-c", "while [ true ]; do echo 'Hello'; sleep 10; done | tee -a /logs/hello.txt" ]
|
||||
volumeMounts:
|
||||
- name: workdir1
|
||||
mountPath: /logs
|
||||
subPathExpr: $(POD_NAME)
|
||||
readOnly: false
|
||||
restartPolicy: Never
|
||||
volumes:
|
||||
- name: workdir1
|
||||
hostPath:
|
||||
path: /var/log/pods
|
||||
```
|
||||
|
||||
|
||||
## 容器内路径
|
||||
|
||||
`mountPath` 数据卷被挂载到容器的路径,不能包含 `:`
|
||||
|
||||
## 权限
|
||||
|
||||
容器对挂载的数据卷是否具备读写权限,如果 `readOnly` 为 `true`,则只读,否则可以读写(为 `false` 或者不指定)。默认为 `false`
|
||||
|
||||
## 挂载传播
|
||||
|
||||
数据卷的挂载传播(Mount Propagation)由 Pod 的 `spec.containers[*].volumeMounts.mountPropagation` 字段控制。可选的取值有:
|
||||
@ -48,7 +131,3 @@ meta:
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart docker
|
||||
```
|
||||
|
||||
## 数据卷
|
||||
|
||||
## 数据卷内子路径
|
||||
|
||||
@ -11,16 +11,15 @@ Kuboard v1.0.x 的更新说明
|
||||
|
||||
**优化**
|
||||
|
||||
* 工作负载的名称前缀为可选添加
|
||||
* 存储类列表为空时,提示当前没有存储类
|
||||
* 集群中事件过多时,名称空间页面渲染时间过长
|
||||
* Secret 填写 docker 地址时,是否要写 http://
|
||||
|
||||
**BUG 修复**
|
||||
|
||||
* 工作负载编辑器 --> Ingress --> 注解被错误写成标签了
|
||||
|
||||
|
||||
* Prometheus 监控
|
||||
* 工作负载编辑器 --> 容器组 --> 容忍 -- 正在开发
|
||||
* kubernetes 1.16.1
|
||||
* HostAliases
|
||||
* Limit Range
|
||||
|
||||
|
||||
Reference in New Issue
Block a user