summarylogtreecommitdiffstats
path: root/k9s-openstack-plugins.yaml
blob: b92729c81728bec20da8c91219c95a318310698d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
plugins:
  openstack-logs:
    shortCut: l
    confirm: false
    description: View logs of openstack machine
    scopes:
      - openstackmachines
    background: false
    command: bash
    args:
      - -c
      - |
        secretName="$(kubectl -n "$NAMESPACE" get openstackmachine "$NAME" -o jsonpath='{.spec.identityRef.name}')"
        envs=( $(kubectl -n "$NAMESPACE" get secret "$secretName" -o jsonpath='{.data.clouds\.yaml}' | base64 -d | yq -r '.clouds.openstack | {OS_AUTH_TYPE: .["auth_type"], OS_AUTH_URL: .auth["auth_url"], OS_APPLICATION_CREDENTIAL_ID: .auth["application_credential_id"], OS_APPLICATION_CREDENTIAL_SECRET: .auth["application_credential_secret"], OS_REGION_NAME: .["region_name"], OS_INTERFACE: .interface, OS_IDENTITY_API_VERSION: .["identity_api_version"]} | to_entries[] | "\(.key)=\(.value)"') )
          #while true; do
          #  env "${envs[@]}" openstack console log show "$(kubectl -n "$NAMESPACE" get openstackmachine "$NAME" -o jsonpath='{.spec.instanceID}')"
          #  sleep 1
          #done | awk '!x[$0]++' | lnav
        env "${envs[@]}" openstack console log show "$(kubectl -n "$NAMESPACE" get openstackmachine "$NAME" -o jsonpath='{.spec.instanceID}')" | exec lnav
  openstack-shell-teutonetescloud-images:
    shortCut: i
    confirm: false
    description: Enter openstack shell for cloud images
    scopes:
      - teutonetescloud
    background: false
    command: bash
    args:
      - -c
      - |
        secretName="$(kubectl get teutonetescloud "$NAME" -o yaml | yq -r '.spec.identityRef.name')"
        envs=( $(kubectl -n "t8se-system" get secret "$secretName" -o jsonpath='{.data.clouds\.yaml}' | base64 -d | yq -r '.clouds.openstack | {OS_AUTH_PLUGIN: "password", OS_AUTH_URL: .auth["auth_url"], OS_USERNAME: .auth["username"], OS_PASSWORD: .auth["password"], OS_USER_DOMAIN_NAME: .auth["user_domain_name"], OS_DOMAIN_NAME: .auth["domain_name"], OS_REGION_NAME: .["region_name"], OS_INTERFACE: .interface, OS_IDENTITY_API_VERSION: .["identity_api_version"]} | to_entries[] | "\(.key)=\(.value)"') )
        imageProjectID="$(kubectl get teutonetescloud "$NAME" -o jsonpath='{.status.imageProject.id}')"
        exec env -u OS_APPLICATION_CREDENTIAL_ID -u OS_APPLICATION_CREDENTIAL_SECRET -u OS_AUTH_TYPE -u OS_AUTH_URL -u OS_IDENTITY_API_VERSION -u OS_INTERFACE -u OS_REGION_NAME "${envs[@]}" OS_PROJECT_ID=$imageProjectID zsh
  openstack-shell-teutonetescloud:
    shortCut: o
    confirm: false
    description: Enter openstack shell for cloud
    scopes:
      - teutonetescloud
    background: false
    command: bash
    args:
      - -c
      - |
        secretName="$(kubectl get teutonetescloud "$NAME" -o yaml | yq -r '.spec.identityRef.name')"
        envs=( $(kubectl -n "t8se-system" get secret "$secretName" -o jsonpath='{.data.clouds\.yaml}' | base64 -d | yq -r '.clouds.openstack | {OS_AUTH_PLUGIN: "password", OS_AUTH_URL: .auth["auth_url"], OS_USERNAME: .auth["username"], OS_PASSWORD: .auth["password"], OS_USER_DOMAIN_NAME: .auth["user_domain_name"], OS_DOMAIN_NAME: .auth["domain_name"], OS_REGION_NAME: .["region_name"], OS_INTERFACE: .interface, OS_IDENTITY_API_VERSION: .["identity_api_version"]} | to_entries[] | "\(.key)=\(.value)"') )
        exec env -u OS_APPLICATION_CREDENTIAL_ID -u OS_APPLICATION_CREDENTIAL_SECRET -u OS_AUTH_TYPE -u OS_AUTH_URL -u OS_IDENTITY_API_VERSION -u OS_INTERFACE -u OS_REGION_NAME -u OS_SHELL "${envs[@]}" zsh
  openstack-shell:
    shortCut: o
    confirm: false
    description: Enter openstack shell for cluster
    scopes:
      - teutonetescluster
      - cluster
    background: false
    command: bash
    args:
      - -c
      - |
        secretName="$(kubectl -n "$NAMESPACE" get openstackcluster -l cluster.x-k8s.io/cluster-name="$NAME" -o yaml | yq -r '.items[0].spec.identityRef.name')"
        envs=( $(kubectl -n "$NAMESPACE" get secret "$secretName" -o jsonpath='{.data.clouds\.yaml}' | base64 -d | yq -r '.clouds.openstack | {OS_AUTH_TYPE: .["auth_type"], OS_AUTH_URL: .auth["auth_url"], OS_APPLICATION_CREDENTIAL_ID: .auth["application_credential_id"], OS_APPLICATION_CREDENTIAL_SECRET: .auth["application_credential_secret"], OS_REGION_NAME: .["region_name"], OS_INTERFACE: .interface, OS_IDENTITY_API_VERSION: .["identity_api_version"]} | to_entries[] | "\(.key)=\(.value)"') )
        exec env OS_SHELL=true "${envs[@]}" zsh
  workload-k9s:
    shortCut: k
    confirm: false
    description: Open K9s in workload cluster
    scopes:
      - teutonetescluster
      - cluster
    background: false
    command: bash
    args:
      - -ec
      - |
        NEW_KUBECONFIG="$(mktemp -p "$XDG_RUNTIME_DIR")"
        trap 'rm -f $NEW_KUBECONFIG' EXIT
        kubectl -n $NAMESPACE get secrets ${NAME}-kubeconfig -o jsonpath='{.data.value}' | base64 -d > "$NEW_KUBECONFIG"
        env KUBECONFIG="$NEW_KUBECONFIG" k9s
  cluster-shell:
    shortCut: s
    confirm: false
    description: Enter shell with KUBECONFIG and openstack credentials for cluster
    scopes:
      - teutonetescluster
      - cluster
    background: false
    command: capo-shell
    args:
      - $NAMESPACE
      - $NAME