-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_create.js
More file actions
36 lines (32 loc) · 1.06 KB
/
api_create.js
File metadata and controls
36 lines (32 loc) · 1.06 KB
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
const accessToken = await getAccessToken(); // Hier rufst du das Access Token ab
// Azure Kubernetes API URL für das Erstellen eines Pods
const apiUrl = `https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Kubernetes/connectedClusters/<aks-cluster-name>/runCommand?api-version=2021-08-01`;
const podSpec = {
// YAML oder JSON-Definition des Containers
apiVersion: "v1",
kind: "Pod",
metadata: { name: "mein-container" },
spec: {
containers: [
{
name: "mein-container",
image: "mein-docker-image", // Dein Docker-Image
ports: [{ containerPort: 80 }],
},
],
},
};
async function createContainer() {
try {
const response = await axios.post(apiUrl, podSpec, {
headers: {
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
});
console.log("Container erstellt:", response.data);
} catch (error) {
console.error("Fehler beim Erstellen des Containers:", error);
}
}
createContainer();