Skip to content

Commit b86df12

Browse files
authored
feature: add ske service + examples (#3)
1 parent 4531057 commit b86df12

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+9170
-0
lines changed

examples/ske/create_cluster.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import os
2+
3+
from stackit.ske.api.default_api import DefaultApi
4+
from stackit.ske.models.create_or_update_cluster_payload import (
5+
CreateOrUpdateClusterPayload,
6+
)
7+
from stackit.ske.models.kubernetes import Kubernetes
8+
from stackit.ske.models.nodepool import Nodepool
9+
from stackit.ske.models.machine import Machine
10+
from stackit.ske.models.volume import Volume
11+
from stackit.ske.models.image import Image
12+
13+
from stackit.core.configuration import Configuration
14+
15+
16+
project_id = os.getenv("PROJECT_ID")
17+
volume_type = "storage_premium_perf0"
18+
19+
# Create a new API client, that uses default authentication and configuration
20+
config = Configuration()
21+
client = DefaultApi(config)
22+
23+
# Get available options
24+
options_resonse = client.list_provider_options()
25+
26+
# Create a new instance using the first option for everything
27+
cluser_name = "cl-name"
28+
create_instance_payload = CreateOrUpdateClusterPayload(
29+
kubernetes=Kubernetes(version=options_resonse.kubernetes_versions[0].version),
30+
nodepools=[
31+
Nodepool(
32+
availability_zones=[options_resonse.availability_zones[0].name],
33+
machine=Machine(
34+
image=Image(
35+
name=options_resonse.machine_images[0].name,
36+
version=options_resonse.machine_images[0].versions[0].version,
37+
),
38+
type=options_resonse.machine_types[0].name,
39+
),
40+
maximum=3,
41+
minimum=2,
42+
name="my-nodepool",
43+
volume=Volume(
44+
size=20,
45+
type=volume_type,
46+
),
47+
)
48+
],
49+
)
50+
client.create_or_update_cluster(project_id, cluser_name, create_instance_payload)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
3+
from stackit.ske.api.default_api import DefaultApi
4+
from stackit.core.configuration import Configuration
5+
6+
project_id = os.getenv("PROJECT_ID")
7+
8+
# Create a new API client, that uses default authentication and configuration
9+
config = Configuration()
10+
client = DefaultApi(config)
11+
12+
# Get all ske instances
13+
response = client.list_clusters(project_id)
14+
15+
# Rotate credentials on all instances
16+
for cluster in response.items:
17+
client.start_credentials_rotation(project_id, cluster.name)

examples/ske/delete_clusters.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
3+
from stackit.ske.api.default_api import DefaultApi
4+
from stackit.core.configuration import Configuration
5+
6+
project_id = os.getenv("PROJECT_ID")
7+
8+
# Create a new API client, that uses default authentication and configuration
9+
config = Configuration()
10+
client = DefaultApi(config)
11+
12+
# List all ske clusters
13+
response = client.list_clusters(project_id)
14+
15+
# Delete all cluster
16+
for cluster in response.items:
17+
client.delete_cluster(project_id, cluster.name)

examples/ske/list_clusters.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os
2+
3+
from stackit.ske.api.default_api import DefaultApi
4+
from stackit.core.configuration import Configuration
5+
6+
project_id = os.getenv("PROJECT_ID")
7+
8+
# Create a new API client, that uses default authentication and configuration
9+
config = Configuration()
10+
client = DefaultApi(config)
11+
12+
# List all ske instances
13+
print(client.list_clusters(project_id))

services/ske/pyproject.toml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
[project]
2+
name = "stackit-ske"
3+
version = "1.0.0"
4+
authors = [
5+
{ name="STACKIT Kubernetes Engine (SKE) Team", email="team@openapitools.org" },
6+
]
7+
description = "SKE-API"
8+
#readme = "README.md"
9+
#license = "NoLicense"
10+
requires-python = ">=3.8"
11+
classifiers = [
12+
"Programming Language :: Python :: 3",
13+
"License :: OSI Approved :: Apache Software License",
14+
"Operating System :: OS Independent",
15+
]
16+
dependencies = [
17+
"requests ~= 2.32.3",
18+
"python_dateutil ~= 2.5.3",
19+
"pydantic ~= 2.9.2",
20+
"stackit-core ~= 0.0.1",
21+
]
22+
23+
[project.optional-dependencies]
24+
dev = [
25+
"black >= 24.8.0",
26+
"pytest ~= 8.3.2",
27+
"flake8 ~= 7.1.0",
28+
"flake8-black ~= 0.3.6",
29+
"flake8-pyproject ~= 1.2.3",
30+
"flake8-quotes ~= 3.4.0",
31+
"flake8-bandit ~= 4.1.1",
32+
"flake8-bugbear ~= 24.8.19",
33+
"flake8-eradicate ~= 1.5.0",
34+
"flake8-eol ~= 0.0.8",
35+
"autoimport ~= 1.6.1",
36+
"isort ~= 5.13.2",
37+
]
38+
39+
[project.urls]
40+
Homepage = "https://github.com/stackitcloud/stackit-sdk-python-beta"
41+
Issues = "https://github.com/stackitcloud/stackit-sdk-python-beta/issues"
42+
43+
[build-system]
44+
requires = ["setuptools"]
45+
build-backend = "setuptools.build_meta"
46+
47+
[tool.black]
48+
line-length = 120
49+
exclude = """
50+
/(
51+
.eggs
52+
| .git
53+
| .hg
54+
| .mypy_cache
55+
| .nox
56+
| .pants.d
57+
| .tox
58+
| .venv
59+
| _build
60+
| buck-out
61+
| build
62+
| dist
63+
| node_modules
64+
| venv
65+
)/
66+
"""
67+
68+
[tool.isort]
69+
profile = 'black'
70+
71+
[tool.flake8]
72+
exclude= [".eggs", ".git", ".hg", ".mypy_cache", ".tox", ".venv", ".devcontainer", "venv", "_build", "buck-out", "build", "dist"]
73+
statistics = true
74+
show-source = false
75+
max-line-length = 120
76+
# E203,W503 and E704 are incompatible with the formatter black
77+
# W291 needs to be disabled because some doc-strings get generated with trailing whitespace but black won't re-format comments
78+
ignore = ["E203", "W503", "E704", "W291"]
79+
inline-quotes = '"'
80+
docstring-quotes = '"""'
81+
multiline-quotes = '"""'
82+
ban-relative-imports = true
83+
per-file-ignores = """
84+
# asserts are fine in tests, tests shouldn't be build optimized
85+
./tests/*: S101,
86+
# F841: some variables get generated but may not be used, depending on the api-spec
87+
# E501: long descriptions/string values might lead to lines that are too long
88+
./stackit/*/models/*: F841,E501
89+
# F841: some variables get generated but may not be used, depending on the api-spec
90+
# E501: long descriptions/string values might lead to lines that are too long
91+
# B028: stacklevel for deprecation warning is irrelevant
92+
./stackit/*/api/default_api.py: F841,B028,E501
93+
"""
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# coding: utf-8
2+
3+
# flake8: noqa
4+
5+
"""
6+
SKE-API
7+
8+
The SKE API provides endpoints to create, update, delete clusters within STACKIT portal projects and to trigger further cluster management tasks.
9+
10+
The version of the OpenAPI document: 1.1
11+
Generated by OpenAPI Generator (https://openapi-generator.tech)
12+
13+
Do not edit the class manually.
14+
""" # noqa: E501 docstring might be too long
15+
16+
17+
__version__ = "1.0.0"
18+
19+
# import apis into sdk package
20+
from stackit.ske.api.default_api import DefaultApi
21+
from stackit.ske.api_client import ApiClient
22+
23+
# import ApiClient
24+
from stackit.ske.api_response import ApiResponse
25+
from stackit.ske.configuration import HostConfiguration
26+
from stackit.ske.exceptions import (
27+
ApiAttributeError,
28+
ApiException,
29+
ApiKeyError,
30+
ApiTypeError,
31+
ApiValueError,
32+
OpenApiException,
33+
)
34+
35+
# import models into sdk package
36+
from stackit.ske.models.acl import ACL
37+
from stackit.ske.models.argus import Argus
38+
from stackit.ske.models.availability_zone import AvailabilityZone
39+
from stackit.ske.models.cluster import Cluster
40+
from stackit.ske.models.cluster_status import ClusterStatus
41+
from stackit.ske.models.cluster_status_state import ClusterStatusState
42+
from stackit.ske.models.create_kubeconfig_payload import CreateKubeconfigPayload
43+
from stackit.ske.models.create_or_update_cluster_payload import (
44+
CreateOrUpdateClusterPayload,
45+
)
46+
from stackit.ske.models.credentials import Credentials
47+
from stackit.ske.models.credentials_rotation_state import CredentialsRotationState
48+
from stackit.ske.models.cri import CRI
49+
from stackit.ske.models.dns import DNS
50+
from stackit.ske.models.extension import Extension
51+
from stackit.ske.models.hibernation import Hibernation
52+
from stackit.ske.models.hibernation_schedule import HibernationSchedule
53+
from stackit.ske.models.image import Image
54+
from stackit.ske.models.kubeconfig import Kubeconfig
55+
from stackit.ske.models.kubernetes import Kubernetes
56+
from stackit.ske.models.kubernetes_version import KubernetesVersion
57+
from stackit.ske.models.list_clusters_response import ListClustersResponse
58+
from stackit.ske.models.login_kubeconfig import LoginKubeconfig
59+
from stackit.ske.models.machine import Machine
60+
from stackit.ske.models.machine_image import MachineImage
61+
from stackit.ske.models.machine_image_version import MachineImageVersion
62+
from stackit.ske.models.machine_type import MachineType
63+
from stackit.ske.models.maintenance import Maintenance
64+
from stackit.ske.models.maintenance_auto_update import MaintenanceAutoUpdate
65+
from stackit.ske.models.network import Network
66+
from stackit.ske.models.nodepool import Nodepool
67+
from stackit.ske.models.project_response import ProjectResponse
68+
from stackit.ske.models.project_state import ProjectState
69+
from stackit.ske.models.provider_options import ProviderOptions
70+
from stackit.ske.models.runtime_error import RuntimeError
71+
from stackit.ske.models.taint import Taint
72+
from stackit.ske.models.time_window import TimeWindow
73+
from stackit.ske.models.volume import Volume
74+
from stackit.ske.models.volume_type import VolumeType
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# flake8: noqa
2+
3+
# import apis into api package
4+
from stackit.ske.api.default_api import DefaultApi

0 commit comments

Comments
 (0)