# How to programmatically create Traefik resources through Kubernetes Operator

**URL:** <https://community.traefik.io/t/how-to-programmatically-create-traefik-resources-through-kubernetes-operator/15140>\
**Category:** Traefik v2\
**Tags:** rest-api, kubernetes-ingress, kubernetes-crd\
**Created:** [July 18, 2022, 7:25am UTC](https://community.traefik.io/t/how-to-programmatically-create-traefik-resources-through-kubernetes-operator/15140 "2022-07-18T07:25:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paoloyx](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/paoloyx/32/3363_2.png) [@paoloyx](https://community.traefik.io/u/paoloyx)\
**Post date:** [July 18, 2022, 7:25am UTC](https://community.traefik.io/t/how-to-programmatically-create-traefik-resources-through-kubernetes-operator/15140/1 "2022-07-18T07:25:55Z")

</div>

Hi, we're investigating the possibility to programmatically create Traefik V2 resources (e.g. Middlewares and IngressRoutes) by means of a golang Kubernetes Operator, that would watch for specific resources (in this case a standard Kubernetes Ingress) and then would create a Middleware/IngressRoute accordingly to that Ingress specifications.

What is the best practice here? I've not found a Traefik cliend sdk to be used with our Go code.  
We were thinking about using exposed rest apis, but from documentation it seems to me that are read-only? [Traefik API Documentation - Traefik](https://doc.traefik.io/traefik/operations/api/#endpoints)

So should we create Yaml dinamically "by hand"?

---

<div class="post-metadata">

**Author:** ![paoloyx](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/paoloyx/32/3363_2.png) [@paoloyx](https://community.traefik.io/u/paoloyx)\
**Post date:** [July 22, 2022, 3:35pm UTC](https://community.traefik.io/t/how-to-programmatically-create-traefik-resources-through-kubernetes-operator/15140/2 "2022-07-22T15:35:26Z")

</div>

The problem was with my wrong understanding about how Go operators work. I was very easily able to do what I wanted by importing this dependency into the `go.mod` file —\>

```auto
require (
   [...]
   github.com/traefik/traefik/v2 v2.8.1
   [...]
)

```

Then Traefik CRDs were instantly available into the code of my operator, and I was able to create Traefik resources into a target cluster

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [July 25, 2022, 3:36pm UTC](https://community.traefik.io/t/how-to-programmatically-create-traefik-resources-through-kubernetes-operator/15140/3 "2022-07-25T15:36:09Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
