Get Started with Kubernetes API
Once you create a CloudFlow Project you can deploy your first container using the Kubernetes API.
Use kubectl config to create a context
Let's configure kubectl
to communicate with your environment.
- If you haven't already, obtain your API token.
- Use the CloudFlow Console to navigate to the Projects page where you will see your
Kubernetes API
URL on your Prokect.
Define CloudFlow as a cluster using your Kubernetes API URL
:
Ubuntu
KUBERNETES_API="https://0123456789.kube.api.section.io/" # Retrieve from https://console.section.io environment page
kubectl config set-cluster section \
--certificate-authority=/etc/ssl/certs/ca-certificates.crt \
--server=$KUBERNETES_API_URL/MacOS
KUBERNETES_API="https://0123456789.kube.api.section.io/" # Retrieve from https://console.section.io environment page
kubectl config set-cluster section \
--certificate-authority=/usr/local/etc/ca-certificates/cert.pem \
--server=$KUBERNETES_API_URL/
If you don't have the file /etc/ssl/certs/ca-certificates.crt
because you're on non-WSL-Windows, you can obtain an equivalent file here: CA certificates
Save your API token
kubectl config set-credentials section-user \
--token=$CLOUDFLOW_API_TOKEN
Create the execution context
kubectl config set-context my-section-application \
--cluster=section \
--user=section-user \
--namespace=default
Switch to the new context
kubectl config use-context my-section-application
Validate your setup
kubectl version
More information about cluster, credential, and context information can be found in the Kubernetes documentation
Deploy a web server to the CloudFlow Edge for HTTP workload
Next we'll place an nginx webserver at the edge using a Kubernetes Deployment object. The nginx webserver container used in this example comes from the official nginx images on the DockerHub registry.
Create a Deployment object
Create a yaml file, such as my-first-edge-application.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.21.6
imagePullPolicy: Always
resources:
requests:
memory: ".5Gi"
cpu: "500m"
limits:
memory: ".5Gi"
cpu: "500m"
ports:
- containerPort: 80
note
You can also use an image from a private registry as a part of your deployment. You can achieve this by creating a secret object containing the image pull credentials and specifying the same in your deployment object. You can read more about how to do this here.
Use kubectl to apply your Deployment
Deploy your application
kubectl apply -f my-first-edge-application.yaml
See your deployment running on CloudFlow
kubectl get deployment nginx-deployment
See the pods running on CloudFlow's network
kubectl get pods -o wide
The -o wide
switch shows where the pod is running according to the default AEE location optimization strategy. Ultimately you will have NxM pods running in the CloudFlow Composable Edge Cloud, where N is the number of replicas, and M is the number of edge locations where your workload is present.