Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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”:

  1. You are logged in to the PFCP portal.
  2. 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.

  1. Navigate to the Namespaces page in the portal.

  2. Open the Create Namespace interface.

    • Cluster Name: Select the cluster you intend to use.
    • Namespace Name: org-<organization-name>--<any-unique-value> 2
  3. Click the Create button to initiate the Namespace creation process.

  4. Set the created Namespace as the default Namespace for kubectl commands.

    $ kubectl config set-context --current --namespace=<your-created-namespace-name>
    
  5. 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.

  1. Execute the following command to create a Deployment that runs podinfo:

    $ kubectl create deployment podinfo --image=stefanprodan/podinfo --port=9898
    deployment.apps/podinfo created
    
  2. Verify that the Pod has started successfully.

    $ kubectl get pod
    NAME                       READY   STATUS    RESTARTS   AGE
    podinfo-554c877494-p58gf   1/1     Running   0          25s
    
  3. 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
    
  4. 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>   ...
    
  5. 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.

  1. Access the Grafana dashboard. You can reach it via the link displayed on the portal’s home page.

  2. From the hamburger icon in the top-left corner, navigate to Dashboards > kube-prometheus > Kubernetes / Compute Resources / Pod to view Pod resource usage. Select the appropriate Namespace and Pod name from the dropdown menu. You should see a screen similar to the following:

    Monitoring Pod resource usage in Grafana

  3. 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
    
  4. Verify that the podinfo scraping was successful and metrics are being collected. Access Prometheus’s web UI and select Status > Targets from the top tab. If you see <your-created-namespace-name>/podinfo/0 listed in the targets with a status of Up, the scraping is functioning correctly.

    Verifying target addition in Prometheus

  5. The collected metrics can be visualized in Grafana. Open the Grafana dashboard and select Explore from 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 /metrics endpoint was called.

    sum by (pod) (rate(promhttp_metric_handler_requests_total{namespace="<your-created-namespace>", job="podinfo"}[$__rate_interval]))
    

    Visualizing Pod metrics in Grafana


  1. In PFCP, the created Namespace will be treated as a sub-namespace. For detailed information, please refer to the Glossary.

  2. The suffix must be different from any existing Namespaces. When conducting this tutorial with multiple users, we recommend using usernames as suffixes.

  3. For detailed information on workload deployment, please refer to the official documentation.

  4. podinfo provides Prometheus-compatible metrics via /metrics.