Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Understanding Kubernetes Object Management
Akshay Rao
Akshay Rao

Posted on

     

Understanding Kubernetes Object Management

Introduction

There are three ways to create and manage Kubernetes objects.

  1. Imperative commands
  2. Imperative object configuration
  3. Declarative object configuration

We will go through each way one by one.

Imperative commands

When we want to operate directly on live objects in an cluster we can use the imperative commands, the commands are directly written on the kubectl command line as a argument or flags.
Example:- In this a pod is created using nginx image.
Image 1
PROS

  • Imperative way can be used when only a single step is required to do changes in the cluster.

CONS

  • don’t incorporate processes for change review.
  • don't offer a change-related audit trail.
  • give just the live sources of records.
  • don't offer a template for making new things.
  • If there are many definition like labels, annotations, names and etc cannot be added at once and it is time consuming.

Imperative object configuration

As we saw in the imperative commands that to add definition to a pod has to done one by one inorder to overcome the difficulty we can use the imperative object configuration in which we can create a yml file, list all the definitions of the pod and run it.
Example:- we are creating a pod name web-declarative from a web-deployment.yml file.

apiVersion: v1kind: Podmetadata:  name: web-declarative  annotations:    site: blogspec: containers:    - name: web      image: nginx:1.17.1
Enter fullscreen modeExit fullscreen mode

Image 2

PROS

  • The yml file can be soted in source control system like git.
  • Can review changes before push and audit trails.
  • It can be used as template to create new objects.
  • When compared to declarative object configuration is much simpler to understand.

CONS

  • Requires basic understanding of schema.
  • Works best on files not on directories.
  • The next replacement will not take into account changes made to live objects if they are not reflected in configuration files.

Declarative object configuration

When using declarative object configuration, a user manipulates locally stored object configuration files, but the user does not specify the actions to be executed on the files. By usingkubectl, create, update, and delete operations are automatically identified for each individual object. This makes it possible to work on directories, where various procedures may be required for various items.

Example:-

Image 3

Image 4

PROS

  • Even if they are not merged back into the configuration files, modifications performed directly to live objects are kept.
  • Declarative object configuration offers better directory support and per-object operation type (new, patch, delete) detection.

CONS

  • When outcomes are unexpected, declarative object configuration is more difficult to debug and comprehend.
  • Complex merge and patch processes are produced by using partial updates and diffs.

Conclusion

These are the three ways to operate with kubernetes objects.
I hope this helps you to understand.
Suggest me in comments in which topic in kubernetes you would like to read?
Thank you

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Devops Engineer
  • Location
    Tokyo,Japan
  • Joined

More fromAkshay Rao

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp