首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >fabric8:添加配置映射

fabric8:添加配置映射
EN

Stack Overflow用户
提问于 2020-11-25 21:13:59
回答 1查看 295关注 0票数 0

我已经能够使用fabric8插件构建我的spring引导服务镜像并将其部署到openshift中。

我需要添加一些configmap。

我曾尝试在src/main/fabric8中添加一个striaghtforward configmap.yml

目前,我收到了这样的消息:

代码语言:javascript
复制
[INFO] --- fabric8-maven-plugin:4.4.1:resource (default-cli) @ connector ---
[INFO] F8: Using Container image name of namespace: arxius-linia
[INFO] F8: Running generator spring-boot
[INFO] F8: spring-boot: Using Container image fabric8/java-centos-openjdk11-jdk:1.6.3 as base / builder
[INFO] F8: using resource templates from /home/jeusdi/projects/arxius-linia/connector/src/main/fabric8
[INFO] F8: fmp-controller: Adding a default Deployment
[INFO] F8: fmp-service: Adding a default service 'connector' with ports [8080]
[WARNING] F8: fmp-git: Could not detect any git remote
[WARNING] F8: fmp-git: Could not detect any git remote
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  20.839 s
[INFO] Finished at: 2020-11-25T14:08:29+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.fabric8:fabric8-maven-plugin:4.4.1:resource (default-cli) on project connector: Execution default-cli of goal io.fabric8:fabric8-maven-plugin:4.4.1:resource failed.: NullPointerException -> [Help 1]

我的configmap.yml是:

代码语言:javascript
复制
data:
  application.properties: |
    spring.profiles.active=dev

我当前相关的pom.xml配置是:

代码语言:javascript
复制
<build>
    <plugins>
        <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>fabric8-maven-plugin</artifactId>
            <version>4.4.1</version>
        </plugin>
   </plugins>
</build>

它基于零配置。

关于如何添加我的configmap.yml有什么想法吗

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-02-09 15:13:56

我来自Fabric8/Eclipse JKube团队。

正如我在评论中提到的,你应该尝试切换到Eclipse JKube,因为它将在未来得到支持。Migrating to Eclipse JKube就像运行这个目标一样简单:

代码语言:javascript
复制
$ mvn org.eclipse.jkube:kubernetes-maven-plugin:migrate

我用这个版本的kubernetes-maven-plugin在一个my demo projects中试用了您的ConfigMap资源片段

代码语言:javascript
复制
      <plugin>
        <groupId>org.eclipse.jkube</groupId>
        <artifactId>kubernetes-maven-plugin</artifactId>
        <version>1.1.0</version>
        <executions>
          <execution>
            <goals>
              <goal>resource</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

我在我的src/main/jkube目录中添加了你的ConfigMap

代码语言:javascript
复制
eclipse-jkube-sample-with-resource-fragments : $ cat src/main/jkube/second-configmap.yaml 
data:
  application.properties: |
    spring.profiles.active=dev

当我做mvn k8s:resource k8s:apply时,我能够看到ConfigMap是如何创建的:

代码语言:javascript
复制
eclipse-jkube-sample-with-resource-fragments : $ mvn k8s:resource k8s:apply
[INFO] Scanning for projects... 
[INFO] 
[INFO] -------< org.eclipse.jkube.quickstarts.maven:external-resources >-------
[INFO] Building Eclipse JKube :: Quickstarts :: Maven :: External Resources 1.1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- kubernetes-maven-plugin:1.1.0:resource (default-cli) @ external-resources ---
[INFO] k8s: Running generator spring-boot
[INFO] k8s: spring-boot: Using Docker image quay.io/jkube/jkube-java-binary-s2i:0.0.9 as base / builder
[INFO] k8s: Using resource templates from /home/rohaan/work/repos/eclipse-jkube-sample-with-resource-fragments/src/main/jkube                                                                                                 
[INFO] k8s: jkube-controller: Adding a default Deployment
[INFO] k8s: jkube-healthcheck-spring-boot: Adding readiness probe on port 8080, path='/health', scheme='HTTP', with initial delay 10 seconds                                                                                  
[INFO] k8s: jkube-healthcheck-spring-boot: Adding liveness probe on port 8080, path='/health', scheme='HTTP', with initial delay 180 seconds                                                                                  
[INFO] k8s: jkube-service-discovery: Using first mentioned service port '80' 
[INFO] k8s: jkube-revision-history: Adding revision history limit to 2
[INFO] k8s: validating /home/rohaan/work/repos/eclipse-jkube-sample-with-resource-fragments/target/classes/META-INF/jkube/kubernetes/ribbon-serviceaccount.yml resource                                                       
[INFO] k8s: validating /home/rohaan/work/repos/eclipse-jkube-sample-with-resource-fragments/target/classes/META-INF/jkube/kubernetes/external-resources-service.yml resource                                                  
[INFO] k8s: validating /home/rohaan/work/repos/eclipse-jkube-sample-with-resource-fragments/target/classes/META-INF/jkube/kubernetes/game-config-env-file-configmap.yml resource                                              
[INFO] k8s: validating /home/rohaan/work/repos/eclipse-jkube-sample-with-resource-fragments/target/classes/META-INF/jkube/kubernetes/second-configmap.yml resource                                                            
[INFO] k8s: validating /home/rohaan/work/repos/eclipse-jkube-sample-with-resource-fragments/target/classes/META-INF/jkube/kubernetes/external-resources-deployment.yml resource
[INFO] k8s: validating /home/rohaan/work/repos/eclipse-jkube-sample-with-resource-fragments/target/classes/META-INF/jkube/kubernetes/my-ingress-ingress.yml resource
[INFO] 
[INFO] --- kubernetes-maven-plugin:1.1.0:apply (default-cli) @ external-resources ---
[INFO] k8s: Using Kubernetes at https://192.168.39.102:8443/ in namespace default with manifest /home/rohaan/work/repos/eclipse-jkube-sample-with-resource-fragments/target/classes/META-INF/jkube/kubernetes.yml 
[INFO] k8s: Creating a ServiceAccount from kubernetes.yml namespace default name ribbon
[INFO] k8s: Created ServiceAccount: target/jkube/applyJson/default/serviceaccount-ribbon-1.json
[INFO] k8s: Creating a Service from kubernetes.yml namespace default name external-resources
[INFO] k8s: Created Service: target/jkube/applyJson/default/service-external-resources-1.json
[INFO] k8s: Creating a ConfigMap from kubernetes.yml namespace default name game-config-env-file
[INFO] k8s: Created ConfigMap: target/jkube/applyJson/default/configmap-game-config-env-file-1.json
[INFO] k8s: Creating a ConfigMap from kubernetes.yml namespace default name second
[INFO] k8s: Created ConfigMap: target/jkube/applyJson/default/configmap-second-1.json
[INFO] k8s: Creating a Deployment from kubernetes.yml namespace default name external-resources
[INFO] k8s: Created Deployment: target/jkube/applyJson/default/deployment-external-resources-1.json
[INFO] k8s: Applying Ingress my-ingress from kubernetes.yml
[INFO] k8s: HINT: Use the command `kubectl get pods -w` to watch your pods start up
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.821 s
[INFO] Finished at: 2021-02-09T12:37:38+05:30
[INFO] ------------------------------------------------------------------------

当我检查时,我能够看到在default名称空间中创建的ConfigMap

代码语言:javascript
复制
eclipse-jkube-sample-with-resource-fragments : $ kubectl get configmap second -o yaml
apiVersion: v1
data:
  application.properties: |
    spring.profiles.active=dev
kind: ConfigMap
metadata:
  creationTimestamp: "2021-02-09T07:07:37Z"
...
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65005417

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档