这里装完后发现2.190.3版本太老 好多依赖插件报错
所以用2.204.1的底包又重新打了一版镜像
这里遇到一个小坑 apply后Jenkins的版本还是2.190.3 最后发现是node节点上的镜像没有自动更新 这和deployment里面的pull镜像策略有关imagePullPolicy: IfNotPresent
[root@alice001 ~]# docker pull jenkins/jenkins:2.190.3
[root@alice001 ~]# docker tag jenkins/jenkins:2.190.3 harbor.od.com/public/jenkins:v2.190.3
[root@alice001 ~]# docker push !$
[root@alice001 ~]# mkdir -p /data/dockerfile/jenkins
[root@alice001 ~]# cd /data/dockerfile/jenkins
[root@alice001 jenkins]# ssh-keygen -t rsa -b 2048 -C "742359324@qq.com" -N "" -f /root/.ssh/id_rsa
[root@alice001 jenkins]# vim config.json
[root@alice001 jenkins]# cat config.json
{
"auths": {
"harbor.od.com": {
"auth": "ZGsxaW46ZGsxMjM0NTY3OA=="
}
}
}
[root@alice001 jenkins]# cp /root/.ssh/id_rsa .
[root@alice001 jenkins]# curl -fsSL get.docker.com -o get-docker.sh
[root@alice001 jenkins]# ll
total 48
-rw-r--r-- 1 root root 109 Feb 21 17:13 config.json
-rw-r--r-- 1 root root 349 Feb 21 16:35 Dockerfile
-rw-r--r-- 1 root root 13857 Feb 21 17:25 get-docker.sh
-rw------- 1 root root 1679 Feb 21 17:15 id_rsa
[root@alice001 jenkins]# chmod +x get-docker.sh
[root@alice001 jenkins]# docker build . -t harbor.od.com/infra/jenkins:v2.190.3
[root@alice001 jenkins]# docker push harbor.od.com/infra/jenkins:v2.190.3
集群节点
[root@alice002 ~]# kubectl create ns infra
namespace/infra created
[root@alice002 ~]# kubectl get namespaces
NAME STATUS AGE
default Active 22d
infra Active 5s
kube-node-lease Active 22d
kube-public Active 22d
kube-system Active 22d
[root@alice002 ~]# kubectl create secret docker-registry harbor --docker-server=harbor.od.com --docker-username=admin --docker-password=123456 -n infra
secret/harbor created
[root@alice002 ~]# kubectl describe secrets harbor -n infra
Name: harbor
Namespace: infra
Labels: <none>
Annotations: <none>
Type: kubernetes.io/dockerconfigjson
Data
====
.dockerconfigjson: 106 bytes
[root@alice002 ~]# mkdir /mnt/jenkins/jenkins_home -p
[root@alice002 ~]# kubectl create -f http://k8s-yaml.od.com/jenkins/deployment.yaml
[root@alice002 ~]# kubectl create -f http://k8s-yaml.od.com/jenkins/svc.yaml
[root@alice002 ~]# kubectl create -f http://k8s-yaml.od.com/jenkins/ingress.yaml
[root@alice002 ~]# kubectl get pod -n infra
NAME READY STATUS RESTARTS AGE
jenkins-66799565d8-n7w6m 1/1 Running 0 111s
[root@alice002 ~]# kubectl exec -it -n infra jenkins-66799565d8-n7w6m /bin/bash
root@jenkins-66799565d8-n7w6m:/# date
Sat Feb 27 09:23:26 CST 2021
root@jenkins-66799565d8-n7w6m:/# whoami
root
root@jenkins-66799565d8-n7w6m:/# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8cc34715487c harbor.od.com/infra/jenkins "/sbin/tini -- /usr/…" 2 minutes ago Up 2 minutes k8s_jenkins_jenkins-66799565d8-n7w6m_infra_c5547368-5d0b-4b11-ab65-29f2c307a343_0
352e13a62c2b harbor.od.com/public/pause:latest "/pause" 2 minutes ago Up 2 minutes k8s_POD_jenkins-66799565d8-n7w6m_infra_c5547368-5d0b-4b11-ab65-29f2c307a343_0
437d50a3df43 harbor.od.com/public/dashboard "/dashboard --insecu…" 6 days ago Up 6 days k8s_kubernetes-dashboard_kubernetes-dashboard-5f569597fd-8np2d_kube-system_776a2503-1677-4f5d-9ec9-c25c6bef0d9d_0
3955db0dcd0d harbor.od.com/public/pause:latest "/pause" 6 days ago Up 6 days k8s_POD_kubernetes-dashboard-5f569597fd-8np2d_kube-system_776a2503-1677-4f5d-9ec9-c25c6bef0d9d_0
a254b5cf6c0c harbor.od.com/public/traefik "/entrypoint.sh --ap…" 6 days ago Up 6 days k8s_traefik-ingress_traefik-ingress-wz2r7_kube-system_26a65cfe-301f-4b3c-8fff-21435a7953bc_0
f889c0d91be5 harbor.od.com/public/pause:latest "/pause" 6 days ago Up 6 days 0.0.0.0:81->80/tcp k8s_POD_traefik-ingress-wz2r7_kube-system_26a65cfe-301f-4b3c-8fff-21435a7953bc_110
935d7bd6116c harbor.od.com/public/coredns "/coredns -conf /etc…" 7 days ago Up 7 days k8s_coredns_coredns-6b6c4f9648-g6btt_kube-system_23494f2d-d804-4828-891a-b9759709421a_0
b4b2d96ff898 harbor.od.com/public/pause:latest "/pause" 7 days ago Up 7 days k8s_POD_coredns-6b6c4f9648-g6btt_kube-system_23494f2d-d804-4828-891a-b9759709421a_0
b38f8273621e harbor.od.com/public/nginx "nginx -g 'daemon of…" 8 days ago Up 8 days k8s_my-nginx_nginx-ds-v96dl_default_d8f3a5cd-752d-47fa-ae72-beca54f1d2dd_0
27860de8cecf harbor.od.com/public/pause:latest "/pause" 8 days ago Up 8 days k8s_POD_nginx-ds-v96dl_default_d8f3a5cd-752d-47fa-ae72-beca54f1d2dd_0
root@jenkins-66799565d8-n7w6m:/# ls ~/.docker/config.json
/root/.docker/config.json
root@jenkins-66799565d8-n7w6m:/# cat ~/.docker/config.json
{
"auths": {
"harbor.od.com": {
"auth": "YWRaW46ZsxRaWMM0NTY3OA=="
}
}
}
root@jenkins-66799565d8-n7w6m:/#
root@jenkins-66799565d8-n7w6m:/# docker login harbor.od.com
Authenticating with existing credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
root@jenkins-66799565d8-n7w6m:/#
[root@alice002 ~]# kubectl exec -it -n infra jenkins-6bdbd96b6-2sp2n /bin/bash
root@jenkins-6bdbd96b6-2sp2n:/#
root@jenkins-6bdbd96b6-2sp2n:/# ssh -i /root/.ssh/id_rsa -T git@gitee.com 將公钥添加到gitee之后测试是否通
Warning: Permanently added 'gitee.com,117.28.245.92' (ECDSA) to the list of known hosts.
Hi 最爱下一站 (DeployKey)! You've successfully authenticated, but GITEE.COM does not provide shell access.
Note: Perhaps the current use is DeployKey.
Note: DeployKey only supports pull/fetch operations
root@jenkins-6bdbd96b6-2sp2n:/#
做域名解析
[root@alice001 jenkins]# cat /var/named/od.com.zone
$ORIGIN od.com.
$TTL 600 ; 10 minutes
@ IN SOA dns.od.com. dnsadmin.od.com. (
2021012910 ; serial
10800 ; refresh (3 hours)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS dns.od.com.
$TTL 60 ; 1 minute
dns A 47.243.20.250
harbor A 172.23.187.175
k8s-yaml A 47.243.20.250
traefik A 47.243.20.250
dashboard A 47.243.20.250
jenkins A 172.23.187.175
[root@alice001 jenkins]#
[root@alice001 jenkins]# systemctl restart named
[root@alice001 jenkins]# dig -t A jenkins.od.com @172.23.187.175 +short
172.23.187.175
[root@alice001 jenkins]#
[root@alice003 updates]# sed -i 's#http:\/\/updates.jenkins-ci.org\/download#https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins#g' default.json
[root@alice003 updates]# sed -i 's#http:\/\/www.google.com#https:\/\/www.baidu.com#g' default.json
[root@alice003 jenkins_home]# cat /mnt/jenkins/jenkins_home/secrets/initialAdminPassword
d1b60f1b171248fcb778dbd244206d78
[root@alice003 jenkins_home]#
这里的账户密码在spinnaker的deployment文件里面有用到
这个url是 Jenkins URL
变量的值 所以我填了内网的域名
但是进去之后报错
参考这个修改一下 https://blog.csdn.net/fxy0325/article/details/88131947
搜索并安装蓝海插件blue ocean
给jenkins配置maven环境
cd /src/
wget https://archive.apache.org/dist/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
tar xf apache-maven-3.6.1-bin.tar.gz
mv apache-maven-3.6.1 /infra_volume/jenkins/jenkins_home/maven-3.6.1-8u232
[root@alice002 maven-3.6.1-8u232]# cat >conf/settings.xml <<'EOF'
> <?xml version="1.0" encoding="UTF-8"?>
> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
> <pluginGroups>
> </pluginGroups>
> <proxies>
> </proxies>
> <servers>
> </servers>
> <mirrors>
> <mirror>
> <id>nexus-aliyun</id>
> <mirrorOf>*</mirrorOf>
> <name>Nexus aliyun</name>
> <url>http://maven.aliyun.com/nexus/content/groups/public</url>
> </mirror>
> </mirrors>
> <profiles>
> </profiles>
> </settings>
> EOF
[root@alice001 jenkins]# docker pull stanleyws/jre8:8u112
[root@alice001 jenkins]# docker tag stanleyws/jre8:8u112 harbor.od.com/public/jre:8u112
[root@alice001 jenkins]# docker push harbor.od.com/public/jre:8u112
服务端代码 如果需要clone代码可以给我key
https://gitee.com/dkaiyun/dubbo-demo-service