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

[Feature Request] Support get the dynamic port of the k3d cluster #645

Open
LinuxSuRen opened this issue Nov 16, 2023 · 0 comments
Open
Labels
feature New feature or request
Milestone

Comments

@LinuxSuRen
Copy link

Is your feature request related to a problem? Please describe.
I'm trying to create a k3d cluster via API of autok3s in a CI stage. Then deploy my application into that cluster. But I cannot get the port which exposed by k3d dynamically.

Describe the solution you'd like
Return the exposed port via the following API:

/v1/clusters/k3d-name?link=nodes

Describe alternatives you've considered
None.

Additional context
In case of anyone want to reproduce it easily. Please see the following YAML file. And you can get atest from [here](run -p bin/test.yaml).

atest run -p bin/test.yaml

#!api-testing
# yaml-language-server: $schema=https://linuxsuren.github.io/api-testing/api-testing-schema.json
name: testing
param:
  k3sname: "{{randAlpha 4}}"
  server: "localhost"
  port: "9090"
items:
- name: createk3s
  request:
    api: http://{{.param.server}}:{{.param.port}}/v1/clusters
    method: POST
    body: |
      {
        "datastore-cafile-content": "",
        "datastore-certfile-content": "",
        "datastore-keyfile-content": "",
        "master": "1",
        "master-extra-args": "",
        "masters-memory": "",
        "name": "{{.param.k3sname}}",
        "network": "",
        "registry": "",
        "registry-content": "",
        "token": "",
        "worker": "1",
        "worker-extra-args": "",
        "workers-memory": "",
        "rollback": true,
        "provider": "k3d",
        "options": {
            "api-port": "{{.param.server}}:0",
            "envs": null,
            "gpus": "",
            "image": "docker.io/rancher/k3s:v1.27.6-k3s1",
            "labels": null,
            "masters-memory": "",
            "no-image-volume": false,
            "no-lb": false,
            "ports": ["30000:30000"],
            "volumes": null,
            "workers-memory": ""
        }
      }
  expect:
    statusCode: 201
- name: getKubeConfig
  before:
    items:
      - httpReady("http://{{.param.server}}:{{.param.port}}/v1/clusters/k3d-{{.param.k3sname}}?link=nodes", 300, "data.status == 'Running'")
  request:
    api: http://{{.param.server}}:{{.param.port}}/v1/clusters/k3d-{{.param.k3sname}}?action=download-kubeconfig
    method: POST
    header:
      Accept: application/json
  after:
    items:
      - writeFile("a.log", current.config)
      - command("helm install --kubeconfig a.log atest helm/api-testing --set persistence.enabled=false --set service.type=NodePort --set service.nodePort=30000")
@LinuxSuRen LinuxSuRen added the feature New feature or request label Nov 16, 2023
@JacieChao JacieChao added this to the backlog milestone Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Development

No branches or pull requests

2 participants