Client-go: Parsing K8s yaml spec into client-go data structures

Created on 12 Apr 2020  路  10Comments  路  Source: kubernetes/client-go

Hi,
I am having one yml file i.e test.yml which contains:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: pod-delete-sa
  namespace: default
  labels:
    name: pod-delete-sa
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
  name: pod-delete-sa
  namespace: default
  labels:
    name: pod-delete-sa
rules:
- apiGroups: ["","litmuschaos.io","batch","apps"]
  resources: ["pods","deployments","pods/log","events","jobs","chaosengines","chaosexperiments","chaosresults"]
  verbs: ["create","list","get","patch","update","delete"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
  name: pod-delete-sa
  namespace: default
  labels:
    name: pod-delete-sa
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: pod-delete-sa
subjects:
- kind: ServiceAccount
  name: pod-delete-sa
  namespace: default

I just want to create/apply this file using go-client.
I'm able to do this via kubectl apply -f test.yml
Is there a way to do that via go-client?

Thanks!

lifecyclrotten

Most helpful comment

@uditgaurav @1032231418 I have this question and i write code to implement it, hope can help you.

The code link: https://gist.github.com/pytimer/0ad436972a073bb37b8b6b8b474520fc

All 10 comments

@uditgaurav Did you find a solution?

Not yet @1032231418

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-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@uditgaurav @1032231418 I have this question and i write code to implement it, hope can help you.

The code link: https://gist.github.com/pytimer/0ad436972a073bb37b8b6b8b474520fc

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-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

You can also try parsing the yaml using the solutions provided in this issue and then use this example to effectively apply it.

@uditgaurav @1032231418 I have this question and i write code to implement it, hope can help you.

The code link: https://gist.github.com/pytimer/0ad436972a073bb37b8b6b8b474520fc

nice work

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-testing, kubernetes/test-infra and/or fejta.
/close

@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-testing, kubernetes/test-infra and/or fejta.
/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.

how to pass multiple yaml spec in client go data structure

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jharshman picture jharshman  路  4Comments

tamalsaha picture tamalsaha  路  6Comments

jgrobbel picture jgrobbel  路  3Comments

ghost picture ghost  路  3Comments

AdheipSingh picture AdheipSingh  路  5Comments