From 149325b0d42f922c40bbb6781ed2eb4ca01ba51e Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Wed, 20 Dec 2023 11:03:29 -0500 Subject: [PATCH 1/3] Update `dapr init` CLI reference with Docker network examples (#3901) * update dapr init doc Signed-off-by: Hannah Hunter * Update daprdocs/content/en/reference/cli/dapr-init.md Signed-off-by: Mark Fussell --------- Signed-off-by: Hannah Hunter Signed-off-by: Mark Fussell Co-authored-by: Mark Fussell --- .../content/en/reference/cli/dapr-init.md | 74 +++++++++++++++---- 1 file changed, 60 insertions(+), 14 deletions(-) diff --git a/daprdocs/content/en/reference/cli/dapr-init.md b/daprdocs/content/en/reference/cli/dapr-init.md index bdb93bf5d15..7cc2d86ad7d 100644 --- a/daprdocs/content/en/reference/cli/dapr-init.md +++ b/daprdocs/content/en/reference/cli/dapr-init.md @@ -49,32 +49,44 @@ dapr init [flags] ### Examples -#### Self hosted environment +{{< tabs "Self-hosted" "Kubernetes" >}} -Install Dapr by pulling container images for Placement, Redis and Zipkin. By default these images are pulled from Docker Hub. To switch to Dapr Github container registry as the default registry, set the `DAPR_DEFAULT_IMAGE_REGISTRY` environment variable value to be `GHCR`. To switch back to Docker Hub as default registry, unset this environment variable. +{{% codetab %}} + +**Install** + +Install Dapr by pulling container images for Placement, Redis, and Zipkin. By default, these images are pulled from Docker Hub. ```bash dapr init ``` -You can also specify a specific runtime version. Be default, the latest version is used. +Dapr can also run [Slim self-hosted mode]({{< ref self-hosted-no-docker.md >}}), without Docker. ```bash -dapr init --runtime-version 1.4.0 +dapr init -s ``` -You can also install Dapr with a particular image variant, for example: [mariner]({{< ref "kubernetes-deploy.md#using-mariner-based-images" >}}). +> To switch to Dapr Github container registry as the default registry, set the `DAPR_DEFAULT_IMAGE_REGISTRY` environment variable value to be `GHCR`. To switch back to Docker Hub as default registry, unset this environment variable. + +**Specify a runtime version** + +You can also specify a specific runtime version. Be default, the latest version is used. ```bash -dapr init --image-variant mariner +dapr init --runtime-version 1.13.0 ``` -Dapr can also run [Slim self-hosted mode]({{< ref self-hosted-no-docker.md >}}) without Docker. +**Install with image variant** + +You can also install Dapr with a particular image variant, for example: [mariner]({{< ref "kubernetes-deploy.md#using-mariner-based-images" >}}). ```bash -dapr init -s +dapr init --image-variant mariner ``` +**Use Dapr Installer Bundle** + In an offline or airgap environment, you can [download a Dapr Installer Bundle](https://github.com/dapr/installer-bundle/releases) and use this to install Dapr instead of pulling images from the network. ```bash @@ -87,17 +99,17 @@ Dapr can also run in slim self-hosted mode without Docker in an airgap environme dapr init -s --from-dir ``` -You can also specify a private registry to pull container images from. These images need to be published to private registries as shown below to enable Dapr CLI to pull them successfully via the `dapr init` command - +**Specify private registry** + +You can also specify a private registry to pull container images from. These images need to be published to private registries as shown below to enable Dapr CLI to pull them successfully via the `dapr init` command: 1. Dapr runtime container image(dapr) (Used to run Placement) - dapr/dapr: 2. Redis container image(rejson) - dapr/3rdparty/rejson 3. Zipkin container image(zipkin) - dapr/3rdparty/zipkin -> All the required images used by Dapr needs to be under the`dapr` path. +All the required images used by Dapr needs to be under the `dapr` path. The 3rd party images have to be published under `dapr/3rdparty` path. -> The 3rd party images have to be published under `dapr/3rdparty` path. - -> image-registry uri follows this format - `docker.io/` +`image-registry` uri follows the `docker.io/` format. ```bash dapr init --image-registry docker.io/username @@ -114,7 +126,37 @@ You can specify a different container runtime while setting up Dapr. If you omit dapr init --container-runtime podman ``` -#### Kubernetes environment +**Use Docker network** + +You can deploy local containers into Docker networks, which is useful for deploying into separate networks or when using Docker Compose for local development to deploy applications. + +Create the Docker network. + +```bash +docker network create mynet +``` + +Initialize Dapr and specify the created Docker network. + +```bash +dapr init --network mynet +``` + +Verify all containers are running in the specified network. + +```bash +docker ps +``` + +Uninstall Dapr from that Docker network. + +```bash +dapr uninstall --all --network mynet +``` + +{{% /codetab %}} + +{{% codetab %}} ```bash dapr init -k @@ -149,3 +191,7 @@ Scenario 2 : dapr image hosted under a new/different directory in private regist ```bash dapr init -k --image-registry docker.io/username/ ``` + +{{% /codetab %}} + +{{< /tabs >}} From 00593a517ca4b6e3df38743da485c726f3aa59eb Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Thu, 21 Dec 2023 12:33:47 -0500 Subject: [PATCH 2/3] cross link for debugging and viewing logs Signed-off-by: Hannah Hunter --- .../debugging/debug-k8s/debug-daprd.md | 8 +++++++- .../en/operations/troubleshooting/logs-troubleshooting.md | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/daprdocs/content/en/developing-applications/debugging/debug-k8s/debug-daprd.md b/daprdocs/content/en/developing-applications/debugging/debug-k8s/debug-daprd.md index 3b13efc5aeb..283f8f3c75c 100644 --- a/daprdocs/content/en/developing-applications/debugging/debug-k8s/debug-daprd.md +++ b/daprdocs/content/en/developing-applications/debugging/debug-k8s/debug-daprd.md @@ -11,7 +11,7 @@ description: "How to debug the Dapr sidecar (daprd) on your Kubernetes cluster" Sometimes it is necessary to understand what's going on in the Dapr sidecar (daprd), which runs as a sidecar next to your application, especially when you diagnose your Dapr application and wonder if there's something wrong in Dapr itself. Additionally, you may be developing a new feature for Dapr on Kubernetes and want to debug your code. -his guide will cover how to use built-in Dapr debugging to debug the Dapr sidecar in your Kubernetes pods. +This guide covers how to use built-in Dapr debugging to debug the Dapr sidecar in your Kubernetes pods. To learn how to view logs and troubleshoot Dapr in Kubernetes, see the [Configure and view Dapr logs guide]({{< ref "logs-troubleshooting.md#logs-in-kubernetes-mode" >}}) ## Pre-requisites @@ -87,6 +87,12 @@ Forwarding from [::1]:40000 -> 40000 All done. Now you can point to port 40000 and start a remote debug session to daprd from your favorite IDE. +## Watch the demo + +See the presentation on troubleshooting Dapr on Kubernetes in the [Dapr Community Call #36](https://youtu.be/pniLPRbuLD8?si=bGid7oYSp9cThtiI&t=838). + + + ## Related links - [Overview of Dapr on Kubernetes]({{< ref kubernetes-overview >}}) diff --git a/daprdocs/content/en/operations/troubleshooting/logs-troubleshooting.md b/daprdocs/content/en/operations/troubleshooting/logs-troubleshooting.md index d2316a1fd84..14eb822c194 100644 --- a/daprdocs/content/en/operations/troubleshooting/logs-troubleshooting.md +++ b/daprdocs/content/en/operations/troubleshooting/logs-troubleshooting.md @@ -73,6 +73,8 @@ dapr run node myapp.js ## Logs in Kubernetes mode +> [Learn how to debug `daprd` on Kubernetes.]({{< ref "debug-daprd.md" >}}) + You can set the log level individually for every sidecar by providing the following annotation in your pod spec template: ```yml From 3cac886e6b90f6f9be24e573bf54d231b06eb96d Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Thu, 21 Dec 2023 14:53:45 -0500 Subject: [PATCH 3/3] add debug commands Signed-off-by: Hannah Hunter --- .../debugging/debug-k8s/debug-daprd.md | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/daprdocs/content/en/developing-applications/debugging/debug-k8s/debug-daprd.md b/daprdocs/content/en/developing-applications/debugging/debug-k8s/debug-daprd.md index 283f8f3c75c..24aca6c85a4 100644 --- a/daprdocs/content/en/developing-applications/debugging/debug-k8s/debug-daprd.md +++ b/daprdocs/content/en/developing-applications/debugging/debug-k8s/debug-daprd.md @@ -87,6 +87,56 @@ Forwarding from [::1]:40000 -> 40000 All done. Now you can point to port 40000 and start a remote debug session to daprd from your favorite IDE. +## Commonly used `kubectl` commands + +Use the following common `kubectl` commands when debugging daprd and applications running on Kubernetes. + +Get all pods, events, and services: + +```bash +kubectl get all +kubectl get all --n +kubectl get all --all-namespaces +``` + +Get each specifically: + +```bash +kubectl get pods +``` + +```bash +kubectl get events --n +kubectl get events --sort-by=.metadata.creationTimestamp --n +``` + +```bash +kubectl get services +``` + +Check logs: + +```bash +kubectl logs daprd +kubectl logs +kuebctl logs daprd +kubectl logs +``` + +```bash +kubectl describe pod +kubectl describe deploy +kubectl describe replicaset +``` + +Restart a pod by running the following command: + +```bash +kubectl delete pod +``` + +This causes the `replicaset` controller to restart the pod after the delete. + ## Watch the demo See the presentation on troubleshooting Dapr on Kubernetes in the [Dapr Community Call #36](https://youtu.be/pniLPRbuLD8?si=bGid7oYSp9cThtiI&t=838).