Q's blog

一些个人文档笔记

官方文档:https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/

pod字段

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
34
35
36
37
38
apiVersion: v1
kind: Pod
metadata:
name: dapi-envars-fieldref
spec:
containers:
- name: test-container
image: k8s.gcr.io/busybox
command: [ "sh", "-c"]
args:
- while true; do
echo -en '\n';
printenv MY_NODE_NAME MY_POD_NAME MY_POD_NAMESPACE;
printenv MY_POD_IP MY_POD_SERVICE_ACCOUNT;
sleep 10;
done;
env:
- name: MY_NODE_NAME // 节点名称
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: MY_POD_NAME // pod 名称
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MY_POD_NAMESPACE // 命名空间
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: MY_POD_IP // pod ip
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: MY_POD_SERVICE_ACCOUNT
valueFrom:
fieldRef:
fieldPath: spec.serviceAccountName //serviceAccountName
restartPolicy: Never
阅读全文 »

源码安装

1
2
3
4
5
6
7
8
9
10
cd
wget https://npm.taobao.org/mirrors/node/v14.2.0/node-v14.2.0-linux-x64.tar.xz
tar xf node-v14.2.0-linux-x64.tar.xz
mkdir /Data/apps/src -pv
mv node-v14.2.0-linux-x64 /Data/apps/src/
cd /Data/apps
chown -R `whoami`:`whoami` node./*
ln -s src/node-v14.2.0-linux-x64 node
echo 'PATH=$PATH:/Data/apps/node/bin' >> /etc/profile
source /etc/profile

清理无用的卷

1
2
#dangling的镜像为未被打标签和没有被任何容器引用的镜像。
docker volume rm $(docker volume ls -qf dangling=true)

删除未使用到的镜像

1
docker rmi $(docker images -q -f "dangling=true")

删除已停止的容器

1
docker rm $(docker ps -a -q)

Docker占用磁盘空间查看

1
docker system df

jenkins-docker 启动命令

1
2
3
4
5
6
7
docker run -d -u root --name jenkins \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/libexec/docker:/usr/libexec/docker \
-v /usr/bin/docker:/usr/bin/docker \
-v jenkins:/var/jenkins_home \
-p 80:8080 -p 50000:50000 \
jenkinszh/jenkins-zh:lts
阅读全文 »

修改配置文件

1
2
3
4
5
6
7
8
9
10
11
12
[root@localhost opt]# grep -rn "^[^#]" /etc/gitlab/gitlab.rb 
external_url 'http://192.168.0.8:8080' #如果使用容器要对应端口
gitlab_rails['gitlab_email_from'] = '16253173030@qq.com'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "16253173030@qq.com"
gitlab_rails['smtp_password'] = "###授权码###"
gitlab_rails['smtp_domain'] = "smtp.qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
阅读全文 »

用docker启动的gitlab克隆项目连接为容器名

解决:

重新初始化容器

1
2
3
4
5
6
7
8
9
10
11
docker run \
--detach \
--hostname gitlab.qh.com \
--publish 2222:22 \
--publish 80:80 \
--name gitlab \
--restart unless-stopped \
-v /data/gitlab/etc:/etc/gitlab \
-v /data/gitlab/log:/var/log/gitlab \
-v /data/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:13.6.3-ce.0

改ssh端口

1
2
vim /etc/gitlab/gitlab.rb
gitlab_rails['gitlab_shell_ssh_port'] = 2222

重新编译

1
2
3
gitlab-ctl stop
gitlab-ctl reconfigure
gitlab-ctl start
0%