Add a deployment to kuberntese through api

I am totally new to Kubernetes and what i need to achieve i need to make a call to specific api in my application to add new node to the Kubernetes cluster so i am looking for the best way to do so

To reach an application that you’ve done via Deployments, you may want to look into how Services work. A service selects and routes traffic to pods.

Actually what I really need to have the ability to apply new deployment from an API in web app in docker way I need to start container dynamically when user hit my api

There’s a few things to unpack to allow your application to create new objects like a Deployment.

  • You need to create a ServiceAccount
  • You need a ClusterRole and/or Role that defines the access allowed
  • You need a ClusterRoleBinding and/or RoleBinding that attaches the role to the account
  • You need to attach the Service account to your pod.

ClusterRoles are cluster-wide access while Roles are namespaced.

This topic is discussed in the RBAC and Configuring Service Accounts for Pods sections of the documentation (to name a couple). The Authorization Overview section is also worth a read depending on how in-depth you really want to go on this topic.

As for your application, I would recommend getting to know some of the Client Libraries.

If you need something example-wise to go off of, I wrote an application in bash that will delete pods to be recreated when configmaps are updated here. It uses a ClusterRole, ClusterRoleBinding, and ServiceAccount; as well as auto-mounts the API token to the pod. The script itself curls api-server via DNS kubernetes.default.svc.cluster.local.

I recommend using the client libraries instead of interfacing with the api-server directly.

thank u i really appreciate your help