Home > Mobile >  what's apiGroups in kubernetes?
what's apiGroups in kubernetes?

Time:12-13

`

rules:
  - verbs:
      - get
      - list
    apiGroups:
      - ''
    resources:
      - namespaces
      - pods
      - pods/log
  - verbs:
      - get
      - list
    apiGroups:
      - apps
    resources:
      - deployments

`

I want to know difference between

apiGroups:

  • ''

and

apiGroups:

  • apps

whats the importance of apiGroups in manifests?

CodePudding user response:

The API group in kubernetes identifies which API group needs to target. This is necessary as different API groups can have the same verbs and also Kubernetes is highly extensible and allows for the addition of new APIs that can have verbs and resource names that clash with other APIs.

In the manifest file, The API group “ ” (empty string) represents the core Kubernetes API and it is used for pods : apigroups is “ ” . for Deployment, apigroups is “apps” and “extensions” is used.

Refer to this API Group official doc

CodePudding user response:

When defining roles in Kubernetes if you specify

    rules:
      - verbs:
          - get
          - list
        apiGroups:
          - ''

The - apiGroups: '' indicates the resources belong to the core(also called legacy)API group. Example Pod, Namespaces etc below to the core api group. You can use kubectl api-resources -o wide to see the api resources available in your Kubernetes cluster.

In the below snippet the resource specified is deployments which comes under named apigroup in K8S. The apiGroup for deployment is apps (will vary depending on the Version of K8S you are using)

- verbs:
    - get
    - list
  apiGroups:
    - apps
  resources:
    - deployments

if you run kubectl proxy a sever will start on port on 127.0.0.1:8001. Open this in your browser and type http://127.0.0.1:8001/apis/apps/v1 you will be able to see the details of K8S Deployment

{
    "name": "deployments",
    "singularName": "",
    "namespaced": true,
    "kind": "Deployment",
    "verbs": [
      "create",
      "delete",
      "deletecollection",
      "get",
      "list",
      "patch",
      "update",
      "watch"
    ],
    "shortNames": [
      "deploy"
    ],
    "categories": [
      "all"
    ],
    "storageVersionHash": "somehash"
  }, 

apiGroups are required to specify which API group the resource is a part of

  • Related