mirror of https://github.com/dapr/quickstarts.git
Modified k8s readme to show API logs (#660)
* Modified k8s readme to show API logs Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Changed kind config Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Reverted kind file changes Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Reverting the workflow changes Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Changing docker version Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Changed readme sleeps for kubernetes rollout Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Changed docker install version Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Reverted the docker install version Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Reverted all workflow changes Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Changes based on the review comments Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Update tutorials/hello-kubernetes/README.md Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Reverted the change Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Fixing Python App API logging Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Reduced memory in yaml Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Added kind Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Add cluster info - commented Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Added cluster info Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Added cluster info - commented Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Changed MacOS version Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Reverted yaml file changes Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Removed k8s from quickstarts Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Removed dapr kubernetes for quickstarts Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> Co-authored-by: Mark Fussell <markfussell@gmail.com>
This commit is contained in:
parent
3f54324acb
commit
27d33638f1
|
@ -39,10 +39,10 @@ jobs:
|
|||
KIND_IMAGE_SHA: sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
os: [ubuntu-latest, macos-10.15]
|
||||
steps:
|
||||
- name: Install docker - MacOS
|
||||
if: matrix.os == 'macos-latest'
|
||||
if: matrix.os == 'macos-10.15'
|
||||
uses: docker-practice/actions-setup-docker@1.0.8
|
||||
with:
|
||||
docker_buildx: false
|
||||
|
@ -81,11 +81,11 @@ jobs:
|
|||
cluster_name: kind
|
||||
version: ${{ env.KIND_VERSION }}
|
||||
- name: Install minikube - MacOS
|
||||
if: matrix.os == 'macos-latest'
|
||||
if: matrix.os == 'macos-10.15'
|
||||
run: |
|
||||
brew install kubernetes-cli || brew link --overwrite kubernetes-cli
|
||||
brew install minikube
|
||||
minikube start --memory 1900 --host-only-cidr "192.168.59.1/24"
|
||||
minikube start --driver=virtualbox --memory 4096 --host-only-cidr "192.168.59.1/24"
|
||||
- name: Get KinD info
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
|
@ -173,4 +173,4 @@ jobs:
|
|||
popd
|
||||
- name: Linkcheck README.md
|
||||
run: |
|
||||
make validate
|
||||
make validate
|
||||
|
|
|
@ -47,53 +47,6 @@ jobs:
|
|||
with:
|
||||
docker_buildx: false
|
||||
docker_version: 20.10
|
||||
- name: Configure KinD
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
# Generate a KinD configuration file that uses:
|
||||
# A couple of worker nodes: this is needed to run both
|
||||
# ZooKeeper + Kakfa
|
||||
working-directory: ./
|
||||
run: |
|
||||
cat > kind.yaml <<EOF
|
||||
apiVersion: kind.x-k8s.io/v1alpha4
|
||||
kind: Cluster
|
||||
nodes:
|
||||
- role: control-plane
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
- role: worker
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
- role: worker
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
- role: worker
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
- role: worker
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
EOF
|
||||
|
||||
# Log the generated kind.yaml for easy reference.
|
||||
cat kind.yaml
|
||||
|
||||
- name: Create KinD Cluster - Linux
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
uses: helm/kind-action@v1.0.0
|
||||
with:
|
||||
config: kind.yaml
|
||||
cluster_name: kind
|
||||
version: ${{ env.KIND_VERSION }}
|
||||
- name: Install minikube - MacOS
|
||||
if: matrix.os == 'macos-latest'
|
||||
run: |
|
||||
brew install kubernetes-cli || brew link --overwrite kubernetes-cli
|
||||
brew install minikube
|
||||
minikube start --memory 1900 --host-only-cidr "192.168.59.1/24"
|
||||
- name: Get KinD info
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
kubectl cluster-info --context kind-kind
|
||||
NODE_IP=$(kubectl get nodes \
|
||||
-lkubernetes.io/hostname!=kind-control-plane \
|
||||
-ojsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
|
||||
echo "SERVICE_IP=$NODE_IP" >> $GITHUB_ENV
|
||||
- name: Set up Go ${{ env.GOVER }}
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
|
@ -121,14 +74,6 @@ jobs:
|
|||
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
|
||||
dapr init --runtime-version=${{ env.DAPR_RUNTIME_VERSION }}
|
||||
dapr --version
|
||||
- name: Install Dapr - Kubernetes
|
||||
run: |
|
||||
helm repo add bitnami https://charts.bitnami.com/bitnami
|
||||
helm repo update
|
||||
helm install redis bitnami/redis
|
||||
dapr init -k --runtime-version=${{ env.DAPR_RUNTIME_VERSION }} --wait || kubectl get pods --all-namespaces
|
||||
kubectl get nodes -o wide
|
||||
for pod in `dapr status -k | awk '/dapr/ {print $1}'`; do kubectl describe pod -l app=$pod -n dapr-system ; kubectl logs -l app=$pod -n dapr-system; done
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v2
|
||||
- name: Install utilities dependencies
|
||||
|
|
|
@ -47,53 +47,6 @@ jobs:
|
|||
with:
|
||||
docker_buildx: false
|
||||
docker_version: 20.10
|
||||
- name: Configure KinD
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
# Generate a KinD configuration file that uses:
|
||||
# A couple of worker nodes: this is needed to run both
|
||||
# ZooKeeper + Kakfa
|
||||
working-directory: ./
|
||||
run: |
|
||||
cat > kind.yaml <<EOF
|
||||
apiVersion: kind.x-k8s.io/v1alpha4
|
||||
kind: Cluster
|
||||
nodes:
|
||||
- role: control-plane
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
- role: worker
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
- role: worker
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
- role: worker
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
- role: worker
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
EOF
|
||||
|
||||
# Log the generated kind.yaml for easy reference.
|
||||
cat kind.yaml
|
||||
|
||||
- name: Create KinD Cluster - Linux
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
uses: helm/kind-action@v1.0.0
|
||||
with:
|
||||
config: kind.yaml
|
||||
cluster_name: kind
|
||||
version: ${{ env.KIND_VERSION }}
|
||||
- name: Install minikube - MacOS
|
||||
if: matrix.os == 'macos-latest'
|
||||
run: |
|
||||
brew install kubernetes-cli || brew link --overwrite kubernetes-cli
|
||||
brew install minikube
|
||||
minikube start --memory 1900 --host-only-cidr "192.168.59.1/24"
|
||||
- name: Get KinD info
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
kubectl cluster-info --context kind-kind
|
||||
NODE_IP=$(kubectl get nodes \
|
||||
-lkubernetes.io/hostname!=kind-control-plane \
|
||||
-ojsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
|
||||
echo "SERVICE_IP=$NODE_IP" >> $GITHUB_ENV
|
||||
- name: Set up Go ${{ env.GOVER }}
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
|
@ -121,14 +74,6 @@ jobs:
|
|||
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
|
||||
dapr init --runtime-version=${{ env.DAPR_RUNTIME_VERSION }}
|
||||
dapr --version
|
||||
- name: Install Dapr - Kubernetes
|
||||
run: |
|
||||
helm repo add bitnami https://charts.bitnami.com/bitnami
|
||||
helm repo update
|
||||
helm install redis bitnami/redis
|
||||
dapr init -k --runtime-version=${{ env.DAPR_RUNTIME_VERSION }} --wait || kubectl get pods --all-namespaces
|
||||
kubectl get nodes -o wide
|
||||
for pod in `dapr status -k | awk '/dapr/ {print $1}'`; do kubectl describe pod -l app=$pod -n dapr-system ; kubectl logs -l app=$pod -n dapr-system; done
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v2
|
||||
- name: Install utilities dependencies
|
||||
|
|
|
@ -47,53 +47,6 @@ jobs:
|
|||
with:
|
||||
docker_buildx: false
|
||||
docker_version: 20.10
|
||||
- name: Configure KinD
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
# Generate a KinD configuration file that uses:
|
||||
# A couple of worker nodes: this is needed to run both
|
||||
# ZooKeeper + Kakfa
|
||||
working-directory: ./
|
||||
run: |
|
||||
cat > kind.yaml <<EOF
|
||||
apiVersion: kind.x-k8s.io/v1alpha4
|
||||
kind: Cluster
|
||||
nodes:
|
||||
- role: control-plane
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
- role: worker
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
- role: worker
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
- role: worker
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
- role: worker
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
EOF
|
||||
|
||||
# Log the generated kind.yaml for easy reference.
|
||||
cat kind.yaml
|
||||
|
||||
- name: Create KinD Cluster - Linux
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
uses: helm/kind-action@v1.0.0
|
||||
with:
|
||||
config: kind.yaml
|
||||
cluster_name: kind
|
||||
version: ${{ env.KIND_VERSION }}
|
||||
- name: Install minikube - MacOS
|
||||
if: matrix.os == 'macos-latest'
|
||||
run: |
|
||||
brew install kubernetes-cli || brew link --overwrite kubernetes-cli
|
||||
brew install minikube
|
||||
minikube start --memory 1900 --host-only-cidr "192.168.59.1/24"
|
||||
- name: Get KinD info
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
kubectl cluster-info --context kind-kind
|
||||
NODE_IP=$(kubectl get nodes \
|
||||
-lkubernetes.io/hostname!=kind-control-plane \
|
||||
-ojsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
|
||||
echo "SERVICE_IP=$NODE_IP" >> $GITHUB_ENV
|
||||
- name: Set up Go ${{ env.GOVER }}
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
|
@ -121,14 +74,6 @@ jobs:
|
|||
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
|
||||
dapr init --runtime-version=${{ env.DAPR_RUNTIME_VERSION }}
|
||||
dapr --version
|
||||
- name: Install Dapr - Kubernetes
|
||||
run: |
|
||||
helm repo add bitnami https://charts.bitnami.com/bitnami
|
||||
helm repo update
|
||||
helm install redis bitnami/redis
|
||||
dapr init -k --runtime-version=${{ env.DAPR_RUNTIME_VERSION }} --wait || kubectl get pods --all-namespaces
|
||||
kubectl get nodes -o wide
|
||||
for pod in `dapr status -k | awk '/dapr/ {print $1}'`; do kubectl describe pod -l app=$pod -n dapr-system ; kubectl logs -l app=$pod -n dapr-system; done
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v2
|
||||
- name: Install utilities dependencies
|
||||
|
|
|
@ -96,7 +96,7 @@ component.dapr.io/statestore created
|
|||
|
||||
<!-- STEP
|
||||
name: Deploy Node App
|
||||
sleep: 60
|
||||
sleep: 90
|
||||
expected_stdout_lines:
|
||||
- "service/nodeapp created"
|
||||
- "deployment.apps/nodeapp created"
|
||||
|
@ -121,6 +121,8 @@ This will deploy the Node.js app to Kubernetes. The Dapr control plane will auto
|
|||
|
||||
`dapr.io/app-id: nodeapp` - this assigns a unique id or name to the Dapr application, so it can be sent messages to and communicated with by other Dapr apps.
|
||||
|
||||
`dapr.io/enable-api-logging: "true"` - this is added to node.yaml file by default to see the API logs.
|
||||
|
||||
You'll also see the container image that you're deploying. If you want to update the code and deploy a new image, see **Next Steps** section.
|
||||
|
||||
There are several different ways to access a Kubernetes service depending on which platform you are using. Port forwarding is one consistent way to access a service, whether it is hosted locally or on a cloud Kubernetes provider like AKS.
|
||||
|
@ -293,7 +295,54 @@ Got a new order! Order ID: 3
|
|||
Successfully persisted state
|
||||
```
|
||||
|
||||
## Step 7 - Confirm successful persistence
|
||||
## Step 7 - Observe API call logs
|
||||
|
||||
Now that the Node.js and Python applications are deployed, watch API call logs come through:
|
||||
|
||||
Get the API call logs of the node app:
|
||||
|
||||
<!-- STEP
|
||||
expected_stdout_lines:
|
||||
- 'level=info msg="HTTP API Called: POST /v1.0/state/statestore"'
|
||||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
name: Read nodeapp logs
|
||||
-->
|
||||
|
||||
```bash
|
||||
kubectl logs --selector=app=node -c daprd --tail=-1
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
When save state API calls are made, you should see logs similar to this:
|
||||
|
||||
```
|
||||
time="2022-04-25T22:46:09.82121774Z" level=info msg="HTTP API Called: POST /v1.0/state/statestore" app_id=nodeapp instance=nodeapp-7dd6648dd4-7hpmh scope=dapr.runtime.http-info type=log ver=1.7.2
|
||||
time="2022-04-25T22:46:10.828764787Z" level=info msg="HTTP API Called: POST /v1.0/state/statestore" app_id=nodeapp instance=nodeapp-7dd6648dd4-7hpmh scope=dapr.runtime.http-info type=log ver=1.7.2
|
||||
```
|
||||
|
||||
Get the API call logs of the Python app:
|
||||
|
||||
<!-- STEP
|
||||
expected_stdout_lines:
|
||||
- 'level=info msg="HTTP API Called: POST /neworder"'
|
||||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
name: Read pythonapp logs
|
||||
-->
|
||||
|
||||
```bash
|
||||
kubectl logs --selector=app=python -c daprd --tail=-1
|
||||
```
|
||||
<!-- END_STEP -->
|
||||
|
||||
```
|
||||
time="2022-04-27T02:47:49.972688145Z" level=info msg="HTTP API Called: POST /neworder" app_id=pythonapp instance=pythonapp-545df48d55-jvj52 scope=dapr.runtime.http-info type=log ver=1.7.2
|
||||
time="2022-04-27T02:47:50.984994545Z" level=info msg="HTTP API Called: POST /neworder" app_id=pythonapp instance=pythonapp-545df48d55-jvj52 scope=dapr.runtime.http-info type=log ver=1.7.2
|
||||
```
|
||||
|
||||
## Step 8 - Confirm successful persistence
|
||||
|
||||
Call the Node.js app's order endpoint to get the latest order. Grab the external IP address that you saved before and, append "/order" and perform a GET request against it (enter it into your browser, use Postman, or curl it!):
|
||||
|
||||
|
@ -304,7 +353,7 @@ curl $NODE_APP/order
|
|||
|
||||
You should see the latest JSON in response!
|
||||
|
||||
## Step 8 - Cleanup
|
||||
## Step 9 - Cleanup
|
||||
|
||||
Once you're done, you can spin down your Kubernetes resources by navigating to the `./deploy` directory and running:
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ spec:
|
|||
dapr.io/enabled: "true"
|
||||
dapr.io/app-id: "nodeapp"
|
||||
dapr.io/app-port: "3000"
|
||||
dapr.io/enable-api-logging: "true"
|
||||
spec:
|
||||
containers:
|
||||
- name: node
|
||||
|
|
|
@ -16,6 +16,7 @@ spec:
|
|||
annotations:
|
||||
dapr.io/enabled: "true"
|
||||
dapr.io/app-id: "pythonapp"
|
||||
dapr.io/enable-api-logging: "true"
|
||||
spec:
|
||||
containers:
|
||||
- name: python
|
||||
|
|
Loading…
Reference in New Issue