Warning
This page was translated from the original Japanese version by PLaMo Translate. The Japanese version is authoritative; the English translation may contain inaccuracies.
PFCP Tutorial: Deploying Workloads
This page guides you through deploying server workloads using a cluster and introduces you to monitoring services.
Preliminary Setup
Complete the following steps in the left column under “Connect to Cluster”:
- You are logged in to the PFCP portal.
- Your cluster connection has been configured.
Creating a Namespace
Create a Namespace1 that will be used throughout this tutorial.
Note
Creating Namespaces requires “Organization Administrator” privileges. Regular users will encounter failure when attempting to create a Namespace.
For users with standard privileges, please request assistance from your organization’s Organization Administrator to create a Namespace.
-
Navigate to the Namespaces page in the portal.
-
Open the Create Namespace interface.
- Cluster Name: Select the cluster you intend to use.
- Namespace Name:
org-<organization-name>--<any-unique-value>2
-
Click the Create button to initiate the Namespace creation process.
-
Set the created Namespace as the default Namespace for kubectl commands.
$ kubectl config set-context --current --namespace=<your-created-namespace-name> -
Verify that the Namespace has been created and that the configuration is correct. Run
kubectl get pod- if no errors occur, the configuration is successful. If errors appear, first confirm the Namespace exists, then double-check that your execution command is correct.// Successful configuration case $ kubectl get pod No resources found in <your-created-namespace-name> namespace. // Configuration error case $ kubectl get pod Error from server (Forbidden): pods is forbidden: User "oidc:org-<organization-name>/<username>" cannot list resource "pods" in API group "" in the namespace "<your-created-namespace-name>"
Deploying Workloads
We will execute a sample Pod using PFCP’s Kubernetes cluster3. Additionally, we will expose the deployed Pod to the internet and verify that it can be accessed via a web browser.
For this example, we are using the podinfo container image.
-
Execute the following command to create a Deployment that runs podinfo:
$ kubectl create deployment podinfo --image=stefanprodan/podinfo --port=9898 deployment.apps/podinfo created -
Verify that the Pod has started successfully.
$ kubectl get pod NAME READY STATUS RESTARTS AGE podinfo-554c877494-p58gf 1/1 Running 0 25s -
Next, create a Service to expose the running Pod.
$ cat << EOF | kubectl apply -f - apiVersion: v1 kind: Service metadata: labels: app: podinfo name: podinfo spec: ports: - name: http port: 8080 protocol: TCP targetPort: 9898 selector: app: podinfo EOF service/podinfo created $ kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE podinfo ClusterIP 10.100.212.250 <none> 8080/TCP 77s -
To make the created Service publicly accessible via the internet, create an Ingress.
$ HOST=podinfo-<any-desired-name>.<organization-name>.sr1-01.ingress.pfcomputing.com $ kubectl create ingress podinfo-ingress --class=nginx --rule="${HOST}/*=podinfo:8080" ingress.networking.k8s.io/podinfo-ingress created $ kubectl get ingress NAME CLASS HOSTS ... podinfo-ingress nginx <same-value-as-HOST> ... -
Access
https://<same-value-as-HOST>in your web browser. If the podinfo dashboard appears, the deployment is successful.
Monitoring Verification
PFCP provides Grafana and Prometheus as managed services. We will use these to check the resource usage status of our created Pod.
-
Access the Grafana dashboard. You can reach it via the link displayed on the portal’s home page.
-
From the hamburger icon in the top-left corner, navigate to
Dashboards>kube-prometheus>Kubernetes / Compute Resources / Podto view Pod resource usage. Select the appropriate Namespace and Pod name from the dropdown menu. You should see a screen similar to the following:
-
You can also collect and visualize metrics instrumented in the Pod using Prometheus. As an example, let’s collect metrics for the podinfo Pod created above4.
Create a ServiceMonitor custom resource as follows:
$ cat << EOF | kubectl apply -f - apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: podinfo spec: selector: matchLabels: app: podinfo endpoints: - interval: 30s port: http path: /metrics EOF servicemonitor.monitoring.coreos.com/podinfo created -
Verify that the podinfo scraping was successful and metrics are being collected. Access Prometheus’s web UI and select
Status>Targetsfrom the top tab. If you see<your-created-namespace-name>/podinfo/0listed in the targets with a status ofUp, the scraping is functioning correctly.
-
The collected metrics can be visualized in Grafana. Open the Grafana dashboard and select
Explorefrom the hamburger icon in the top-left corner. For example, running the following PromQL query will display a time-series graph showing the number of times the/metricsendpoint was called.sum by (pod) (rate(promhttp_metric_handler_requests_total{namespace="<your-created-namespace>", job="podinfo"}[$__rate_interval]))
-
In PFCP, the created Namespace will be treated as a sub-namespace. For detailed information, please refer to the Glossary. ↩
-
The suffix must be different from any existing Namespaces. When conducting this tutorial with multiple users, we recommend using usernames as suffixes. ↩
-
For detailed information on workload deployment, please refer to the official documentation. ↩
-
podinfo provides Prometheus-compatible metrics via
/metrics. ↩