Skip to content

Commit 93e21c1

Browse files
committed
feat: api credentials as files
For a simple GitOps workflow, we can mount the Proxmox API credentials into the container as a files. Signed-off-by: Serge Logvinov <[email protected]>
1 parent 384b22c commit 93e21c1

File tree

8 files changed

+235
-57
lines changed

8 files changed

+235
-57
lines changed

.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,20 @@
88
#
99
_cfgs/
1010
bin/
11+
dist/
12+
vendor/
1113
charts/
1214
docs/
15+
examples/
1316
hack/
14-
vendor/
1517
Dockerfile
1618

1719
# other
1820
*.md
1921
*.yml
2022
*.zip
2123
*.sql
24+
/*.yaml/
2225

2326
# cosign
2427
/cosign.key

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ go.work.sum
2525
.env
2626

2727
#
28+
/_cfgs/
2829
/bin/
2930
/dist/
3031
/vendor/
3132
/karpenter-provider-proxmox*
3233
/kubeconfig
3334
/kubeconfig*
34-
/cloud.yaml
35-
/_cfgs/
35+
/*.yaml
3636

3737
# IDEs and editors
3838
/.idea

docs/config.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,23 @@ This file configures the Proxmox Karpenter Provider and defines how it connects
66
clusters:
77
# List of Proxmox clusters
88
- url: https://cluster-api-1.exmple.com:8006/api2/json
9+
910
# Skip the certificate verification, if needed
1011
insecure: false
11-
# Proxmox api token
12+
13+
# Proxmox api credentials
14+
## Username and password (not recommended, use api tokens instead)
15+
username: "root@pam"
16+
password: "password"
17+
## Proxmox api token (recommended)
1218
token_id: "kubernetes@pve!karpenter"
1319
token_secret: "secret"
14-
# Region name, which is cluster name
20+
## Proxmox api token via files, it can be used both with token_id and token_secret
21+
## token_id and token_secret have priority over files
22+
token_id_file: "/path/to/token_id_file"
23+
token_secret_file: "/path/to/token_secret_file"
24+
25+
# Region name, which is cluster name and `topology.kubernetes.io/region` label
1526
region: Region-1
1627

1728
# Add more clusters if needed
@@ -28,6 +39,10 @@ You can define multiple clusters in the `clusters` section.
2839

2940
* `url` - The URL of the Proxmox cluster API.
3041
* `insecure` - Set to `true` to skip TLS certificate verification.
42+
* `username` - The Proxmox username (not recommended, use API tokens instead).
43+
* `password` - The Proxmox password (not recommended, use API tokens instead).
3144
* `token_id` - The Proxmox API token ID.
32-
* `token_secret` - The name of the Kubernetes Secret that contains the Proxmox API token.
45+
* `token_id_file` - The path to a file containing the Proxmox API token ID.
46+
* `token_secret` - The Proxmox API token.
47+
* `token_secret_file` - The path to a file containing the Proxmox API token secret.
3348
* `region` - The name of the region, which is also used as `topology.kubernetes.io/region` label.

go.mod

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/sergelogvinov/karpenter-provider-proxmox
22

3-
go 1.25.0
3+
go 1.25.1
44

55
require (
66
github.com/awslabs/operatorpkg v0.0.0-20250804204931-57066b748e19
@@ -20,7 +20,7 @@ require (
2020
k8s.io/cluster-bootstrap v0.34.0
2121
k8s.io/klog/v2 v2.130.1
2222
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d
23-
sigs.k8s.io/controller-runtime v0.22.0
23+
sigs.k8s.io/controller-runtime v0.22.1
2424
sigs.k8s.io/karpenter v1.6.2
2525
sigs.k8s.io/yaml v1.6.0
2626
)
@@ -47,7 +47,7 @@ require (
4747
github.com/google/uuid v1.6.0 // indirect
4848
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
4949
github.com/inconshreveable/mousetrap v1.1.0 // indirect
50-
github.com/jinzhu/copier v0.3.4 // indirect
50+
github.com/jinzhu/copier v0.4.0 // indirect
5151
github.com/josharian/intern v1.0.0 // indirect
5252
github.com/json-iterator/go v1.1.12 // indirect
5353
github.com/magefile/mage v1.15.0 // indirect
@@ -56,33 +56,33 @@ require (
5656
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
5757
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
5858
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
59-
github.com/prometheus/client_golang v1.23.0 // indirect
59+
github.com/prometheus/client_golang v1.23.2 // indirect
6060
github.com/prometheus/client_model v0.6.2 // indirect
61-
github.com/prometheus/common v0.65.0 // indirect
61+
github.com/prometheus/common v0.66.1 // indirect
6262
github.com/prometheus/procfs v0.17.0 // indirect
6363
github.com/robfig/cron/v3 v3.0.1 // indirect
64-
github.com/spf13/pflag v1.0.9 // indirect
64+
github.com/spf13/pflag v1.0.10 // indirect
6565
github.com/x448/float16 v0.8.4 // indirect
6666
go.uber.org/zap v1.27.0 // indirect
6767
go.yaml.in/yaml/v2 v2.4.2 // indirect
6868
go.yaml.in/yaml/v3 v3.0.4 // indirect
6969
golang.org/x/net v0.43.0 // indirect
70-
golang.org/x/oauth2 v0.30.0 // indirect
71-
golang.org/x/sync v0.16.0 // indirect
72-
golang.org/x/sys v0.35.0 // indirect
73-
golang.org/x/term v0.34.0 // indirect
74-
golang.org/x/text v0.28.0 // indirect
75-
golang.org/x/time v0.12.0 // indirect
70+
golang.org/x/oauth2 v0.31.0 // indirect
71+
golang.org/x/sync v0.17.0 // indirect
72+
golang.org/x/sys v0.36.0 // indirect
73+
golang.org/x/term v0.35.0 // indirect
74+
golang.org/x/text v0.29.0 // indirect
75+
golang.org/x/time v0.13.0 // indirect
7676
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
7777
google.golang.org/protobuf v1.36.8 // indirect
78-
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
78+
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
7979
gopkg.in/inf.v0 v0.9.1 // indirect
8080
k8s.io/apiextensions-apiserver v0.34.0 // indirect
8181
k8s.io/cloud-provider v0.34.0 // indirect
8282
k8s.io/component-base v0.34.0 // indirect
8383
k8s.io/csi-translation-lib v0.34.0 // indirect
84-
k8s.io/kube-openapi v0.0.0-20250814151709-d7b6acb124c3 // indirect
85-
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
84+
k8s.io/kube-openapi v0.0.0-20250905212525-66792eed8611 // indirect
85+
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
8686
sigs.k8s.io/randfill v1.0.0 // indirect
8787
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
8888
)

go.sum

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
7070
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
7171
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
7272
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
73-
github.com/jinzhu/copier v0.3.4 h1:mfU6jI9PtCeUjkjQ322dlff9ELjGDu975C2p/nrubVI=
74-
github.com/jinzhu/copier v0.3.4/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
73+
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
74+
github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
7575
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
7676
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
7777
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
@@ -117,12 +117,12 @@ github.com/pkg/xattr v0.4.9/go.mod h1:di8WF84zAKk8jzR1UBTEWh9AUlIZZ7M/JNt8e9B6kt
117117
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
118118
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
119119
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
120-
github.com/prometheus/client_golang v1.23.0 h1:ust4zpdl9r4trLY/gSjlm07PuiBq2ynaXXlptpfy8Uc=
121-
github.com/prometheus/client_golang v1.23.0/go.mod h1:i/o0R9ByOnHX0McrTMTyhYvKE4haaf2mW08I+jGAjEE=
120+
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
121+
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
122122
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
123123
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
124-
github.com/prometheus/common v0.65.0 h1:QDwzd+G1twt//Kwj/Ww6E9FQq1iVMmODnILtW1t2VzE=
125-
github.com/prometheus/common v0.65.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8=
124+
github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs=
125+
github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
126126
github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0=
127127
github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw=
128128
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
@@ -136,8 +136,9 @@ github.com/sirupsen/logrus v1.9.4-0.20230606125235-dd1b4c2e81af h1:Sp5TG9f7K39yf
136136
github.com/sirupsen/logrus v1.9.4-0.20230606125235-dd1b4c2e81af/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
137137
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
138138
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
139-
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
140139
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
140+
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
141+
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
141142
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
142143
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
143144
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
@@ -173,34 +174,34 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
173174
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
174175
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
175176
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
176-
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
177-
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
177+
golang.org/x/oauth2 v0.31.0 h1:8Fq0yVZLh4j4YA47vHKFTa9Ew5XIrCP8LC6UeNZnLxo=
178+
golang.org/x/oauth2 v0.31.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
178179
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
179180
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
180181
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
181-
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
182-
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
182+
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
183+
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
183184
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
184185
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
185186
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
186187
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
187188
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
188-
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
189-
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
190-
golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
191-
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
189+
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
190+
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
191+
golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ=
192+
golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA=
192193
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
193194
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
194-
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
195-
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
196-
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
197-
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
195+
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
196+
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
197+
golang.org/x/time v0.13.0 h1:eUlYslOIt32DgYD6utsuUeHs4d7AsEYLuIAdg7FlYgI=
198+
golang.org/x/time v0.13.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
198199
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
199200
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
200201
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
201202
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
202-
golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0=
203-
golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw=
203+
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
204+
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
204205
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
205206
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
206207
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -212,8 +213,8 @@ google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXn
212213
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
213214
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
214215
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
215-
gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4=
216-
gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
216+
gopkg.in/evanphx/json-patch.v4 v4.13.0 h1:czT3CmqEaQ1aanPc5SdlgQrrEIb8w/wwCvWWnfEbYzo=
217+
gopkg.in/evanphx/json-patch.v4 v4.13.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
217218
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
218219
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
219220
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
@@ -236,14 +237,14 @@ k8s.io/csi-translation-lib v0.34.0 h1:WhCkq35XATZ+x6NKqI4u7XSYtmucuCN7jDk+mmm9XU
236237
k8s.io/csi-translation-lib v0.34.0/go.mod h1:lZ+vpT3/6hx7GxXcI1mcoHxZSONvxgl2NwawzFnJP4Y=
237238
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
238239
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
239-
k8s.io/kube-openapi v0.0.0-20250814151709-d7b6acb124c3 h1:liMHz39T5dJO1aOKHLvwaCjDbf07wVh6yaUlTpunnkE=
240-
k8s.io/kube-openapi v0.0.0-20250814151709-d7b6acb124c3/go.mod h1:UZ2yyWbFTpuhSbFhv24aGNOdoRdJZgsIObGBUaYVsts=
240+
k8s.io/kube-openapi v0.0.0-20250905212525-66792eed8611 h1:o4oKOsvSymDkZRsMAPZU7bRdwL+lPOK5VS10Dr1D6eg=
241+
k8s.io/kube-openapi v0.0.0-20250905212525-66792eed8611/go.mod h1:kdmbQkyfwUagLfXIad1y2TdrjPFWp2Q89B3qkRwf/pQ=
241242
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d h1:wAhiDyZ4Tdtt7e46e9M5ZSAJ/MnPGPs+Ki1gHw4w1R0=
242243
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
243-
sigs.k8s.io/controller-runtime v0.22.0 h1:mTOfibb8Hxwpx3xEkR56i7xSjB+nH4hZG37SrlCY5e0=
244-
sigs.k8s.io/controller-runtime v0.22.0/go.mod h1:FwiwRjkRPbiN+zp2QRp7wlTCzbUXxZ/D4OzuQUDwBHY=
245-
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE=
246-
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
244+
sigs.k8s.io/controller-runtime v0.22.1 h1:Ah1T7I+0A7ize291nJZdS1CabF/lB4E++WizgV24Eqg=
245+
sigs.k8s.io/controller-runtime v0.22.1/go.mod h1:FwiwRjkRPbiN+zp2QRp7wlTCzbUXxZ/D4OzuQUDwBHY=
246+
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg=
247+
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
247248
sigs.k8s.io/karpenter v1.6.2 h1:WFayZ49CSOaDMku1iYBTsD3A9hOB2yU/U95VcSAJ8KM=
248249
sigs.k8s.io/karpenter v1.6.2/go.mod h1:AxCaeRjv1Pgw/Ff7vT4aqyXcg8v1UdBcfzWMCaKSVjA=
249250
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=

pkg/providers/proxmoxpool/errors.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import "github.com/pkg/errors"
2121
var (
2222
// ErrClustersNotFound is returned when a cluster is not found in the Proxmox
2323
ErrClustersNotFound = errors.New("clusters not found")
24+
// ErrHAGroupNotFound is returned when a ha-group is not found in the Proxmox
25+
ErrHAGroupNotFound = errors.New("ha-group not found")
2426
// ErrRegionNotFound is returned when a region is not found in the Proxmox
2527
ErrRegionNotFound = errors.New("region not found")
28+
// ErrInstanceNotFound is returned when an instance is not found in the Proxmox
29+
ErrInstanceNotFound = errors.New("instance not found")
2630
)

pkg/providers/proxmoxpool/pool.go

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"crypto/tls"
2323
"fmt"
2424
"net/http"
25+
"os"
26+
"strings"
2527

2628
proxmox "github.com/luthermonson/go-proxmox"
2729

@@ -32,13 +34,15 @@ import (
3234

3335
// ProxmoxCluster defines a Proxmox cluster configuration.
3436
type ProxmoxCluster struct {
35-
URL string `yaml:"url"`
36-
Insecure bool `yaml:"insecure,omitempty"`
37-
TokenID string `yaml:"token_id,omitempty"`
38-
TokenSecret string `yaml:"token_secret,omitempty"`
39-
Username string `yaml:"username,omitempty"`
40-
Password string `yaml:"password,omitempty"`
41-
Region string `yaml:"region,omitempty"`
37+
URL string `yaml:"url"`
38+
Insecure bool `yaml:"insecure,omitempty"`
39+
TokenID string `yaml:"token_id,omitempty"`
40+
TokenIDFile string `yaml:"token_id_file,omitempty"`
41+
TokenSecret string `yaml:"token_secret,omitempty"`
42+
TokenSecretFile string `yaml:"token_secret_file,omitempty"`
43+
Username string `yaml:"username,omitempty"`
44+
Password string `yaml:"password,omitempty"`
45+
Region string `yaml:"region,omitempty"`
4246
}
4347

4448
// ProxmoxPool is a Proxmox client pool of proxmox clusters.
@@ -63,6 +67,24 @@ func NewProxmoxPool(ctx context.Context, config []*ProxmoxCluster) (*ProxmoxPool
6367
options = append(options, proxmox.WithHTTPClient(&http.Client{Transport: httpTr}))
6468
}
6569

70+
if cfg.TokenID == "" && cfg.TokenIDFile != "" {
71+
var err error
72+
73+
cfg.TokenID, err = readValueFromFile(cfg.TokenIDFile)
74+
if err != nil {
75+
return nil, err
76+
}
77+
}
78+
79+
if cfg.TokenSecret == "" && cfg.TokenSecretFile != "" {
80+
var err error
81+
82+
cfg.TokenSecret, err = readValueFromFile(cfg.TokenSecretFile)
83+
if err != nil {
84+
return nil, err
85+
}
86+
}
87+
6688
if cfg.Username != "" && cfg.Password != "" {
6789
options = append(options, proxmox.WithCredentials(&proxmox.Credentials{
6890
Username: cfg.Username,
@@ -111,6 +133,7 @@ func (c *ProxmoxPool) CheckClusters(ctx context.Context) error {
111133
return fmt.Errorf("failed to get cluster info in region %s, error: %v", region, err)
112134
}
113135

136+
// Check if we can have permission to list VMs
114137
vms, err := pxCluster.Resources(ctx, "vm")
115138
if err != nil {
116139
return fmt.Errorf("failed to get list of VMs in region %s, error: %v", region, err)
@@ -298,3 +321,16 @@ func (c *ProxmoxPool) DeleteVMByIDInRegion(ctx context.Context, region string, v
298321

299322
// return ""
300323
// }
324+
325+
func readValueFromFile(path string) (string, error) {
326+
if path == "" {
327+
return "", fmt.Errorf("path cannot be empty")
328+
}
329+
330+
content, err := os.ReadFile(path)
331+
if err != nil {
332+
return "", fmt.Errorf("failed to read file '%s': %w", path, err)
333+
}
334+
335+
return strings.TrimSpace(string(content)), nil
336+
}

0 commit comments

Comments
 (0)