Closed jessebot closed 5 months ago
Having issues with this as well, using the example in the docs here as a template:
This one works:
from __future__ import print_function
import time
import kubernetes.client
from kubernetes.client.rest import ApiException
from pprint import pprint
from kubernetes import config
configuration = config.load_kube_config()
with kubernetes.client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = kubernetes.client.CustomObjectsApi(api_client)
group = 'apps' # str | The custom resource's group name
version = 'v1' # str | The custom resource's version
namespace = 'default' # str | The custom resource's namespace
plural = 'deployments' # str | The custom resource's plural name. For TPRs this would be lowercase plural kind.
body = {
'apiVersion': 'apps/v1',
'kind': 'Deployment',
'metadata': {
'name': 'k8s-py-client-nginx'
},
'spec': {
'selector': {
'matchLabels': {
'app': 'nginx'
}
},
'replicas': 1,
'template': {
'metadata': {
'labels': {
'app': 'nginx'
}
},
'spec': {
'containers': [
{
'name': 'nginx',
'image': 'nginx:1.14.2',
'ports': [
{
'containerPort': 80
}
]
}
]
}
}
}
}
try:
api_response = api_instance.create_namespaced_custom_object(group, version, namespace, plural, body)
pprint(api_response)
except ApiException as e:
print("Exception when calling CustomObjectsApi->create_namespaced_custom_object: %s\n" % e)
But this one fails with a 404 error:
from __future__ import print_function
import time
import kubernetes.client
from kubernetes.client.rest import ApiException
from pprint import pprint
from kubernetes import config
configuration = config.load_kube_config()
with kubernetes.client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = kubernetes.client.CustomObjectsApi(api_client)
group = 'cert-manager.io' # str | The custom resource's group name
version = 'v1' # str | The custom resource's version
namespace = 'default'
plural = 'clusterissuers' # str | The custom resource's plural name. For TPRs this would be lowercase plural kind.
body = {
"apiVersion": "cert-manager.io/v1",
"kind": "ClusterIssuer",
"metadata": {
"name": "letsencrypt-testing"
},
"spec": {
"acme": {
"email": "admin@example.net",
"server": "https://acme-staging-v02.api.letsencrypt.org/directory",
"privateKeySecretRef": {
"name": "letsencrypt-testing"
},
"solvers": [
{
"http01": {
"ingress": {
"class": "nginx"
}
}
}
]
}
}
}
try:
api_response = api_instance.create_namespaced_custom_object(group, namespace, version, plural, body)
pprint(api_response)
except ApiException as e:
print("Exception when calling CustomObjectsApi->create_namespaced_custom_object: %s\n" % e)
Error:
Exception when calling CustomObjectsApi->create_namespaced_custom_object: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Audit-Id': '7f3abaf4-2145-490d-a33b-67aade8afda5', 'Cache-Control': 'no-cache, private', 'Content-Type': 'text/plain; charset=utf-8', 'X-Content-Type-Options': 'nosniff', 'X-Kubernetes-Pf-Flowschema-Uid': '70fe66b4-2fc4-4fb5-92a2-31dbfd958c57', 'X-Kubernetes-Pf-Prioritylevel-Uid': 'e8ec24da-c46b-41f5-afb5-8697eb7236ca', 'Date': 'Tue, 15 Aug 2023 19:38:11 GMT', 'Content-Length': '19'})
HTTP response body: 404 page not found
I went through as many past GitHub Issues around this as I could, but couldn't find anything that helped. I ended up just wrapping kubectl
using some existing little libraries I'd written in smol-k8s-lab with rich and subprocess.
I'm still available to help provide any details needed on this issue, but wanted to help others that may feel a bit of writers block in the meantime. 💙
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle stale
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle rotten
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/reopen
/remove-lifecycle rotten
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
@k8s-triage-robot: Closing this issue, marking it as "Not Planned".
What happened (please include outputs or screenshots): I get
HTTP response body: 404 page not found
when I try to create aClusterIssuer
for cert-manager. Here's the full stack trace:What you expected to happen: I expected a
ClusterIssuer
manifest to be created in the ingress namespace.How to reproduce it (as minimally and precisely as possible): Create a cluster with kind and helm install cert-manager:
Verify all the CRDs were created, manually:
This is happening in a small program I'm writing called smol-k8s-lab, but I've extracted just the part that is failing. I mostly grabbed this code from the example in examples/namespaced_custom_object.py:
Example manifest I'd like to apply as regular yaml:
Anything else we need to know?:
Environment:
kubectl version
):Ventura 13.5
python --version
):Python 3.11.4
pip list | grep kubernetes
)kubernetes 27.2.0
Let me know if there's something I'm doing incorrectly here.