创建部署问题时,请参考下面模板,你提供的信息越多,越容易及时获得解答。如果未按模板创建问题,管理员有权关闭问题。
确保帖子格式清晰易读,用 markdown code block 语法格式化代码块。
你只花一分钟创建的问题,不能指望别人花上半个小时给你解答。
操作系统信息
4.19.90-25.43.v2101.ky10.aarch64
Kubernetes版本信息
v1.22.12。 单节点
容器运行时
Docker v19.03.15
KubeSphere版本信息
kubesphere v3.3.1。 kk安装
问题是什么
Jenkinsfile
pipeline {
agent {
node {
label 'maven'
}
}
stages {
stage('拉取代码') {
steps {
git(url: "${GIT_REPOSITORY_URL}/${GITHUB_ACCOUNT}/${APP_NAME}.git", credentialsId: "${GITHUB_CREDENTIAL_ID}", branch: "$BRANCH_NAME", changelog: true, poll: false)
}
}
stage('编译测试') {
steps {
container('maven') {
sh 'mvn clean test'
}
}
}
stage('编译构建') {
steps {
container('maven') {
sh 'mvn clean package -DskipTests'
}
}
}
stage('制作并推送镜像') {
agent none
steps {
container('maven') {
withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD', usernameVariable : 'DOCKER_USERNAME', credentialsId : "$DOCKER_CREDENTIAL_ID" ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker build -f Dockerfile-online -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME .'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME'
}
}
}
}
stage('推送 latest 标签') {
when {
branch 'master'
}
steps {
container('maven') {
sh 'docker tag $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest '
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest '
}
}
}
stage('部署到 k8s Prod 集群') {
when {
branch 'master'
}
steps {
input(id: 'deploy-to-dev', message: 'deploy to K8s Prod?')
container('maven') {
withCredentials([
kubeconfigFile(credentialsId: env.KUBECONFIG_CREDENTIAL_ID, variable: 'KUBECONFIG')]) {
sh 'envsubst < deploy/prod-all-in-one/devops-sample.yaml | kubectl apply -f -'
}
}
}
}
}
environment {
DOCKER_CREDENTIAL_ID = 'demo-harbor'
GITHUB_CREDENTIAL_ID = 'demo-gitee'
KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig'
REGISTRY = 'x.x.x.x:80'
DOCKERHUB_NAMESPACE = 'library'
GITHUB_ACCOUNT = 'xxx'
APP_NAME = 'devops-maven-sample'
GIT_REPOSITORY_URL = 'https://gitee.com'
}
parameters {
string(name: 'BRANCH_NAME', defaultValue: 'master', description: '')
string(name: 'TAG_NAME', defaultValue: '', description: '')
}
}
Dockerfile-online
FROM java:8u92-jre-alpine
WORKDIR /home
COPY target/*.jar /home
ENTRYPOINT java -jar *.jar
最后,容器日志为
Error loading shared library libjli.so: Bad address (needed by /usr/lib/jvm/java-1.8-openjdk/jre/bin/java)
Error relocating /usr/lib/jvm/java-1.8-openjdk/jre/bin/java: JLI_Launch: symbol not found
在谷歌上找到一个类似的问题 docker-library/openjdk#77
尝试了其中的一些方法,问题依旧没有解决。。。