ansible-collections / kubernetes.core

The collection includes a variety of Ansible content to help automate the management of applications in Kubernetes and OpenShift clusters, as well as the provisioning and maintenance of clusters themselves.
Other
216 stars 135 forks source link

k8s module issue when creating a LimitRange for openshift.io/Image & openshift.io/ImageStream in Openshift 4.10 #449

Open vladuhul opened 2 years ago

vladuhul commented 2 years ago

SUMMARY

Message: 'openshift.io/Image' is not one of ['Container', 'PersistentVolumeClaim', 'Pod']" Openshift documentation: https://docs.openshift.com/container-platform/4.10/nodes/clusters/nodes-cluster-limit-ranges.html Normally it creates the LimitRange without a problem but for 4.10 this is not happening.

ISSUE TYPE
COMPONENT NAME

k8s core module creating a LimitRange for openshift.io/Image & openshift.io/ImageStream;

ANSIBLE VERSION 2.10.17
'openshift.io/Image' is not one of ['Container', 'PersistentVolumeClaim', 'Pod']

EDIT:

I have an ansible role which is triggered in a playbook, all through gitlab job.

- name: Create 
  k8s:
    name: ...
    namespace: "{{ ... }}"
    api_version: v1
    host: "{{ ... }}"
    api_key: "{{ ... }}"
    apply: true
    username: "{{ ... }}" 
    validate_certs: no
    state: present
    definition: "{{ lookup('file', 'resource.yaml') }}"
  tags: require
gravesm commented 2 years ago

@vladuhul Thanks for reporting your issue. Can you please provide the version of kubernetes.core you are using and an example playbook that is failing?

vladuhul commented 2 years ago

@gravesm Thank you for taking the time to respond. Yaml in question:

apiVersion: v1
kind: LimitRange
metadata:
  name: core-resource-limits
  namespace: ...
  selfLink: "..."
spec:
  limits:
  - type: Pod
    max:
      cpu: "2"
      memory: "3000Mi"
    min:
      cpu: "5m"
      memory: "20Mi"
  - type: Container
    max:
      cpu: "2"
      memory: "3000Mi"
    min:
      cpu: "5m"
      memory: "20Mi"
    default:
      cpu: "1"
      memory: "500Mi"
    defaultRequest:
      cpu: "10m"
      memory: "60Mi"
  - type: openshift.io/Image
    max:
      storage: 3Gi
  - type: openshift.io/ImageStream
    max:
      openshift.io/image-tags: 30
      openshift.io/images: 50

kubernetes version = 23.3.0

gravesm commented 2 years ago

I am not able to reproduce this using the following playbook:

- hosts: localhost
  tasks:
    - kubernetes.core.k8s:
        kind: Namespace
        name: testing

    - kubernetes.core.k8s:
        definition:
          apiVersion: v1
          kind: LimitRange
          metadata:
            namespace: testing
            name: test-range
          spec:
            limits:
              - type: openshift.io/Image
                max:
                  storage: 1Gi

openshift 4.10.9 kubernetes.core 2.3.1 kubernetes 23.3.0 ansible 2.12.5

vladuhul commented 2 years ago

@gravesm Some remarks are in order to understand the big picture.

I have an ansible role which is triggered in a playbook, all through gitlab job. The ansible role creates the object by referring to the template I posted above. I also tried to use j2 template - same error.

- name: Create 
  k8s:
    name: ...
    namespace: "{{ ... }}"
    api_version: v1
    host: "{{ ... }}"
    api_key: "{{ ... }}"
    apply: true
    username: "{{ ... }}" 
    validate_certs: no
    state: present
    definition: "{{ lookup('file', 'resource.yaml') }}"
  tags: require

kubernetes 23.3.0 ansible.core 2.11.11

How do i find out the kubernetes.core version? EDIT: kubernetes.core 1.2.1

gravesm commented 2 years ago

You can get the kubernetes.core version with ansible-galaxy collection list kubernetes.core

vladuhul commented 2 years ago

@gravesm kubernetes.core 1.2.1

gravesm commented 2 years ago

I am still unable to reproduce this using kubernetes.core 1.2.1. Is there any way you could post the output with extra verbosity enabled (-vvvv) ?