【发布时间】:2022-12-23 04:06:34
【问题描述】:
我能够使用 jenkins 管道发布 Docker 映像,但不能从 nexus 中提取 docker 映像。我使用 kaniko 构建映像。
部署.yml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: test-app
name: test-app
namespace: jenkins
spec:
replicas: 1
selector:
matchLabels:
app: test-app
template:
metadata:
labels:
app: test-app
spec:
hostNetwork: false
containers:
- name: test-app
image: ip_adress/demo:0.1.0
imagePullPolicy: Always
resources:
limits: {}
imagePullSecrets:
- name: registrypullsecret
服务.yml
apiVersion: v1
kind: Service
metadata:
labels:
app: test-app
name: test-app-service
namespace: jenkins
spec:
ports:
- nodePort: 32225
port: 8081
protocol: TCP
targetPort: 8081
selector:
app: test-app
type: NodePort
Jenkins 流水线主脚本
stage ('Build Image'){
container('kaniko'){
script {
sh '''
/kaniko/executor --dockerfile `pwd`/Dockerfile --context `pwd` --destination="$ip_adress:8082/demo:0.1.0" --insecure --skip-tls-verify
'''
}
stage('Kubernetes Deployment'){
container('kubectl'){
withKubeConfig([credentialsId: 'kube-config', namespace:'jenkins']){
sh 'kubectl get pods'
sh 'kubectl apply -f deployment.yml'
sh 'kubectl apply -f service.yml'
}
我创建了一个 Spring boot Java 应用程序的 dockerfile。我已使用 Jenkins 管道将图像发送到 Nexus,但我无法部署它。
kubectl get pod -n jenkins测试应用程序-... 0/1 ImagePullBackOff
kubectl describe pod test-app-.....来自服务器的错误 (NotFound):pods“test-app-..”未找到
docker pull $ip_address:8081/repository/docker-releases/demo:0.1.0```
来自守护程序的错误响应:获取“https://$ip_adress/v2/”:http:server 向 HTTPS 客户端提供 HTTP 响应
ip地址:私有ip地址
如何作为 http 发送?
【问题讨论】:
标签: docker kubernetes jenkins-pipeline nexus3 kaniko