Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to create a setter for an item in array? #3429

Closed
flickerfly opened this issue Jan 8, 2021 · 18 comments
Closed

[Question] How to create a setter for an item in array? #3429

flickerfly opened this issue Jan 8, 2021 · 18 comments
Assignees
Labels
kind/support Categorizes issue or PR as a support question. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@flickerfly
Copy link

I have the following kustomization.yaml and Krmfile. It includes an array of ENV values that I'd like to turn into setters. So far the best I can figure out is a single setter for the entire array. Can I set list items in the array individually?

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namePrefix: minecraft-bedrock-
namespace: bedrock
resources:
- manifests/service.yaml
- manifests/statefulSet.yaml
configMapGenerator:
- name: minecraft-bedrock
  literals: # {"$openapi":"configMapGenerator.name"}
  - EULA="FALSE" # Must accept EULA to use this minecraft server (Set to TRUE)
  - GAMEMODE="survival" # Options=survival, creative, adventure
  - DIFFICULTY="normal" # Options=peaceful, easy, normal, hard
  - DEFAULT_PLAYER_PERMISSION_LEVEL="member" # Options=visitor, member, operator
  - LEVEL_NAME="my_minecraft_world"
  - LEVEL_SEED="33480944"
  - SERVER_NAME="my_minecraft_server"
  - SERVER_PORT="19132"
  - LEVEL_TYPE="DEFAULT" # Options=FLAT, LEGACY, DEFAULT
  - ALLOW_CHEATS="false" # Options=true, false
  - MAX_PLAYERS="10"
  - PLAYER_IDLE_TIMEOUT="30"
  - TEXTUREPACK_REQUIRED="false" # Options=true, false
  - OPS=""
  - MEMBERS=""
  - VISITORS=""
  - ONLINE_MODE="true"
  - WHITE_LIST="false"
  - WHITE_LIST_USERS="commma,separated,names"
  - VIEW_DISTANCE="10" # Performance impact
  - TICK_DISTANCE="4" # Performance impact
  - MAX_THREADS="8" # Performance impact

Krmfile

apiVersion: config.k8s.io/v1alpha1
kind: Krmfile
openAPI:
  definitions:
    io.k8s.cli.setters.configMapGenerator.name:
      type: array
      x-k8s-cli:
        setter:
          name: configMapGenerator.name
          value: ""
          description: "Set Configuration array for Minecraft Bedrock server"
          listValues:
          - EULA="FALSE"
          - GAMEMODE="survival"
          - DIFFICULTY="normal"
          - DEFAULT_PLAYER_PERMISSION_LEVEL="member"
          - LEVEL_NAME="my_minecraft_world"
          - LEVEL_SEED="33480944"
          - SERVER_NAME="my_minecraft_server"
          - SERVER_PORT="19132"
          - LEVEL_TYPE="DEFAULT"
          - ALLOW_CHEATS="false"
          - MAX_PLAYERS="10"
          - PLAYER_IDLE_TIMEOUT="30"
          - TEXTUREPACK_REQUIRED="false"
          - OPS=""
          - MEMBERS=""
          - VISITORS=""
          - ONLINE_MODE="true"
          - WHITE_LIST="false"
          - WHITE_LIST_USERS="commma,separated,names"
          - VIEW_DISTANCE="10"
          - TICK_DISTANCE="4"
          - MAX_THREADS="8"
          required: true
@phanimarupaka
Copy link
Contributor

@flickerfly Thanks for the question. Firstly, are you using setters with kustomize or kpt? If kustomize what is the actual command you used to create the setter for entire array ?

@Shell32-Natsu Shell32-Natsu added the kind/support Categorizes issue or PR as a support question. label Jan 8, 2021
@flickerfly
Copy link
Author

I'm trying to see if I can stick with Kustomize for this (know it is Alpha).

If my bash history is correct, this is the command I issued.

kustomize cfg init base/
kustomize cfg create-setter . configMapGenerator.name [EULA="FALSE",GAMEMODE="survival",DIFFICULTY="normal",DEFAULT_PLAYER_PERMISSION_LEVEL="member",LEVEL_NAME="my_minecraft_world",LEVEL_SEED="33480944",SERVER_NAME="my_minecraft_server",SERVER_PORT="19132",LEVEL_TYPE="DEFAULT",ALLOW_CHEATS="false",MAX_PLAYERS="10",PLAYER_IDLE_TIMEOUT="30",TEXTUREPACK_REQUIRED="false",OPS="",MEMBERS="",VISITORS="",ONLINE_MODE="true",WHITE_LIST="false",WHITE_LIST_USERS="commma,separated,names",VIEW_DISTANCE="10",TICK_DISTANCE="4",MAX_THREADS="8"] --type array --required --field literals

@phanimarupaka
Copy link
Contributor

@flickerfly Cool. Setters are not fully supported in kustomize yet but great to see you use it.

You can do the same to target a particular value.

kustomize cfg create-setter . configMapGenerator.name 'EULA="FALSE"'

@phanimarupaka
Copy link
Contributor

@flickerfly Did that answer your question?

@flickerfly
Copy link
Author

flickerfly commented Jan 9, 2021 via email

@phanimarupaka
Copy link
Contributor

@flickerfly Ahh I see... I wouldn't recommend you to use setters with kustomize. They are not fully supported/documented and will be deprecated soon. Have you tried using kpt instead ? Please try using kpt
https://googlecontainertools.github.io/kpt/installation/
https://googlecontainertools.github.io/kpt/guides/producer/setters/

Here are the steps to perform task above

mkdir flickerfly; cd flickerfly

kpt pkg init .

cat <<EOF >> kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namePrefix: minecraft-bedrock-
namespace: bedrock
resources:
- manifests/service.yaml
- manifests/statefulSet.yaml
configMapGenerator:
- name: minecraft-bedrock
  literals: # {"$openapi":"configMapGenerator.name"}
  - EULA="FALSE" # Must accept EULA to use this minecraft server (Set to TRUE)
  - GAMEMODE="survival" # Options=survival, creative, adventure
  - DIFFICULTY="normal" # Options=peaceful, easy, normal, hard
  - DEFAULT_PLAYER_PERMISSION_LEVEL="member" # Options=visitor, member, operator
  - LEVEL_NAME="my_minecraft_world"
  - LEVEL_SEED="33480944"
  - SERVER_NAME="my_minecraft_server"
  - SERVER_PORT="19132"
  - LEVEL_TYPE="DEFAULT" # Options=FLAT, LEGACY, DEFAULT
  - ALLOW_CHEATS="false" # Options=true, false
  - MAX_PLAYERS="10"
  - PLAYER_IDLE_TIMEOUT="30"
  - TEXTUREPACK_REQUIRED="false" # Options=true, false
  - OPS=""
  - MEMBERS=""
  - VISITORS=""
  - ONLINE_MODE="true"
  - WHITE_LIST="false"
  - WHITE_LIST_USERS="commma,separated,names"
  - VIEW_DISTANCE="10" # Performance impact
  - TICK_DISTANCE="4" # Performance impact
  - MAX_THREADS="8" # Performance impact
EOF

kpt cfg create-setter . server-name 'SERVER_NAME="my_minecraft_server"'

kpt cfg list-setters .

kpt cfg set . server-name 'SERVER_NAME="my_minecraft_server_2"'

Let me know if this helps solve your issue.

cc @mikebz @monopole Advocating users to use setters in kpt instead of kustomize as they are not fully supported.

@seh
Copy link
Contributor

seh commented Jan 11, 2021

Advocating users to use setters in kpt instead of kustomize as they are not fully supported.

I have not been able to find any documentation on the proposed replacement for setters. I've seen mention of "search and replace," which is evocative as a name, but does not constitute a design document. Is there anything we can read today about where the parametric facilities are going?

Also, kpt has been afflicted by its own defects that made kustomize a more attractive choice—mostly for its narrower ambition and its comparative stability. Do you consider that situation to have changed?

@flickerfly
Copy link
Author

@phanimarupaka I suppose that's my answer. Like @seh mentioned, I'm also curious to see where this will end up within kustomize. I'm more interested in what the future of kustomize/kpt management for some sort of search and replace will look which is why I was messing with it on this toy project. I support some thought towards how to integrate as the current smashing of the two together in alpha is a bit awkward.

@LittleChimera
Copy link

@phanimarupaka can you clarify deprecation statement? Is the whole Krmfile going to get deprecated or just some aspects of it?

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 18, 2021
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 17, 2021
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-contributor-experience at kubernetes/community.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-contributor-experience at kubernetes/community.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ChristianCiach
Copy link

Is the whole Krmfile going to get deprecated or just some aspects of it?

Sad to see that this issue, like so many others, are automatically closed without any kind of answer or resolution.

@phanimarupaka phanimarupaka reopened this Aug 22, 2021
@k8s-ci-robot
Copy link
Contributor

@flickerfly: This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Aug 22, 2021
@phanimarupaka
Copy link
Contributor

@natasha41575 Can you please respond to this issue as you have worked on deprecating few commands in kustomize lately.

cc @mikebz

@KnVerey
Copy link
Contributor

KnVerey commented Sep 1, 2021

As discussed in #3953 we will be deprecating all setter-related functionality in Kustomize.

/close

@k8s-ci-robot
Copy link
Contributor

@KnVerey: Closing this issue.

In response to this:

As discussed in #3953 we will be deprecating all setter-related functionality in Kustomize.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

10 participants