0%

Longhorn 是 Kubernetes 的云原生分布式块存储。

Install

注意:在安装 longhorn 之前,需要先在节点上安装 iSCSI:

1
2
yum install -y iscsi-initiator-utils targetcli
systemctl enable --now iscsid

然后安装 longhorn:

1
2
3
helm repo add longhorn https://charts.longhorn.io
kubectl create namespace longhorn-system
helm install longhorn longhorn/longhorn --namespace longhorn-system
Read more »

借助 template 插件可以实现泛域名解析,语法如下:

1
2
3
4
5
6
7
8
template CLASS TYPE [ZONE...] {
match REGEX...
answer RR
additional RR
authority RR
rcode CODE
fallthrough [ZONE...]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
.:53 {
errors
health
ready
template IN A domain.local {
answer "{{ .Name }} 60 IN A 192.168.23.7"
fallthrough
}
forward . 8.8.8.8
cache 30
loop
reload
loadbalance
}

References

默认情况下,Pod 采用的是 dnsPolicy: ClusterFirst 策略, 故 k3s 中 coredns 不会解析外部服务域名,修改 coredns 的 ConfigMap 配置:

httpbin 是一个 HTTP Request & Response Service,你可以向他发送请求,然后他会按照指定的规则将你的请求返回。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpbin
labels:
app: httpbin
spec:
replicas: 3
selector:
matchLabels:
app: httpbin
template:
metadata:
labels:
app: httpbin
spec:
containers:
- name: httpbin
image: kennethreitz/httpbin
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: httpbin
spec:
selector:
app: httpbin
ports:
- protocol: TCP
port: 80
targetPort: 80
Read more »

cert-manager 是一个云原生证书管理开源项目,用于在 Kubernetes 集群中提供 HTTPS 证书并自动续期,支持 Let’s Encrypt / HashiCorp / Vault 这些免费证书的签发。

安装 cert-manager

1
2
3
4
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--version v1.4.0 \
--set installCRDs=true

安装时必须设置installCRDs=true,否则后面安装Issuer会抛出下面错误:

error: no matches for kind “Issuer” in version “cert-manager.io/v1”

Read more »

本文的目标便是将图片转成 .ico 图标。

支持图片格式:

  • png
  • jpg
  • jpeg

依赖:

  • sips:macOS 系统自带的图片处理工具
  • imagemagick:一套开源的、强大且稳定的图片处理工具包,需提前安装 brew install imagemagick

思路:

  1. 先使用 sips 命令得到图片的宽度
  2. 然后再使用 sips 命令生成 iconset
  3. 使用 iconutil 命令将 iconset 转换成 icns 文件
  4. 最后使用 convert 命令将 icns 文件转换成 ico 文件
Read more »

关于如何搭建k3s集群,可以参考我的上一篇文章,本文介绍如何在k3s集群中开启firewall。

下面是一些常用的端口:

PROTOCOL PORT DESCRIPTION
TCP 2376 Node driver Docker daemon TLS port
TCP 2379 Etcd client requests
TCP 2380 Etcd peer communication
TCP 6443 Kubernetes API
UDP 8472 Canal/Flannel VXLAN overlay networking
TCP 9099 Canal/Flannel livenessProbe/readinessProbe
TCP 10250 Kubelet API
TCP 10254 Ingress controller livenessProbe/readinessProbe
TCP / UDP 30000-32767 NodePort port range
Read more »

Error: Kubernetes cluster unreachable: Get “http://localhost:8080/version?timeout=32s": dial tcp [::1]:8080: connect: connection refused

报错原因:

helm v3版本不再需要Tiller,而是直接访问ApiServer来与k8s交互,通过环境变量KUBECONFIG来读取存有ApiServre的地址与token的配置文件地址,默认地址为~/.kube/config。

解决办法:

  • 通过修改环境变量KUBECONFIG来解决这个问题:export KUBECONFIG=/etc/rancher/k3s/k3s.yaml。
  • 或者ln -s /etc/rancher/k3s/k3s.yaml ~/.kube/config。

k3s是经CNCF一致性认证的Kubernetes发行版,专为物联网及边缘计算设计。

集群规划

服务器 用途 配置 IP
k3s-master k3s-server(master节点) 2C2G 10.17.56.20
k3s-agent1 k3s-agent(agent节点1) 2C2G 10.17.56.21
k3s-agent2 k3s-agent(agent节点2) 2C2G 10.17.56.22

这三台机器安装的是CentOS7系统。

Read more »

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
version: 0.1
log:
fields:
service: registry
storage:
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
health:
storagedriver:
enabled: true
interval: 10s
threshold: 3
proxy:
remoteurl: https://gcr.io
1
2
3
4
5
6
7
8
9
10
11
12
13
version: '3.7'

services:
gcr_io:
image: registry
restart: always
labels:
- traefik.http.routers.gcr_io.rule=Host(`gcr.mirrors.yourdomain.com`)
- traefik.http.routers.gcr_io.entrypoints=websecure
- traefik.http.routers.gcr_io.service=gcr_io
- traefik.http.services.gcr_io.loadbalancer.server.port=5000
volumes:
- ./gcr.io.yml:/etc/docker/registry/config.yml

使用docker-compose up -d命令启动代理服务。