jkube icon indicating copy to clipboard operation
jkube copied to clipboard

Disable forced Deployment creation for incomplete image models

Open tipame opened this issue 3 years ago • 7 comments

Description

I have simple module with only one kubernates Service defined in: ../jkube/simple-service.yaml I'm already exclude most enrichers - so i expect only one object to be generated. Actualy resource goal always generate "Deployment/Deployment Config" object. Generated object is incomplete (because where is no info about container image). So if i run apply goal - exception is thrown. I was trying to add exclusion for enricher responsible for Deployment object generation, but fail to find right name in documentation. May be there is another way to change default behavior, or it's a bug?

Info

  • Eclipse JKube version : 1.6.0, 1.5.1, 1.4.0
  • Maven version (mvn -v) : 3.6.8

tipame avatar Feb 18 '22 11:02 tipame

Did you exclude jkube-controller?

manusa avatar Feb 21 '22 06:02 manusa

Ecluding jkube-controller - helped in my case. Thank you! But steel - i think that resource generation of "broken" xml config (no image is supplied) should end with exception.

tipame avatar Feb 21 '22 08:02 tipame

But steel - i think that resource generation of "broken" xml config (no image is supplied) should end with exception.

This one would be hard to tackle, could you provide some reproducer code?

I understand that you end up with a Deployment that has no PodTemplate?

manusa avatar Feb 21 '22 08:02 manusa

I mean exceptional case - when developer forget to add Image tag. Expected behavior of jkube-controller - is exception at resource goal. Actualy it generates config without any exceptions. And you will get exception from API server if you try to apply generated config.

tipame avatar Feb 21 '22 09:02 tipame

It would be really helpful to get some reproducer code to see how we can properly tackle this.

manusa avatar Feb 21 '22 09:02 manusa

My plugin configuration:

<jkube.build.switchToDeployment>true</jkube.build.switchToDeployment>
...
<plugin>
    <groupId>org.eclipse.jkube</groupId>
    <artifactId>openshift-maven-plugin</artifactId>
    <version>1.6.0</version>
    <configuration>
        <namespace>${k8s.namespace}</namespace>
        <apiVersion>v1</apiVersion>
        <recreate>true</recreate>
        <deletePodsOnReplicationControllerUpdate>true</deletePodsOnReplicationControllerUpdate>
        <filter>@</filter>
        <enricher>
            <excludes>
                <exclude>jkube-project-label</exclude>
                <exclude>jkube-service</exclude>
                <exclude>jkube-serviceaccount</exclude>
            </excludes>
        </enricher>
        <mappings>
            <mapping>
                <kind>Endpoints</kind>
                <filenameTypes>endpoints</filenameTypes>
            </mapping>
        </mappings>
        <resources>
            <secrets>
                <secret>
                    <name>${k8s.image.pull.secret}</name>
                    <dockerServerId>${k8s.pull.registry.server.id}</dockerServerId>
                </secret>
            </secrets>
        </resources>
    </configuration>
</plugin>

Also i have 2 yaml files in jkube directory:

apiVersion: v1
kind: Service
metadata:
  name: kafka-service
spec:
  type: ClusterIP
  ports:
    - name: client
      port: 9092
      targetPort: @kafka.external.port@
      protocol: TCP
apiVersion: v1
kind: Endpoints
metadata:
  name: kafka-service
subsets:
  - addresses:
      - ip: @kafka.external.ip@
    ports:
      - name: client
        port: @kafka.external.port@

If you try to execute resource goal - Deployment object wil be created (no errors), but it will fail on apply phase.

tipame avatar Feb 21 '22 12:02 tipame

We already seem to have a check to not generate Deployment or any controller when no image configuration is present:

https://github.com/eclipse/jkube/blob/4cef8d361a73f04161699dd149383b70f60de6ca/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/DefaultControllerEnricher.java#L113

I think Some generator is kicking in your case and generating opinionated Image configuration. Could you please try adding an exclusion for the generator which is getting activated in your case?

<generator>
        <excludes>
               <exclude>java-exec</exclude>
        </excludes>
</generator>

rohanKanojia avatar Jul 08 '22 11:07 rohanKanojia

@tipame: Polite ping, Did you get time to revisit this issue?

rohanKanojia avatar Mar 24 '23 11:03 rohanKanojia

@tipame : polite ping, Would appreciate it if you could provide some feedback regarding this issue? Any reproducer project would help us in investigating whether some generator is kicking in or not.

rohanKanojia avatar Apr 19 '23 09:04 rohanKanojia

@tipame : Is this still an issue? Or were you able to resolve it via some other method?

rohanKanojia avatar Jul 03 '23 12:07 rohanKanojia

@tipame : is it still an issue ? I am closing this issue, feel free to reopen if needed. Thanks!

sunix avatar Jul 20 '23 08:07 sunix