$ dapr run --help # Run a Python application that listens to port 3000: dapr run --app-id myapp --app-port 3000 -- python myapp.py # Run sidecar only: dapr run --app-id myapp
Flags: # 需要研究这个app-id有啥用??? -a, --app-id string The id for your application, used for service discovery --app-max-concurrency int The concurrency level of the application, otherwise is unlimited (default -1) # 业务程序监听的端口 -p, --app-port int The port your application is listening on (default -1) # dapr和app之间的protocol -P, --app-protocol string The protocol (gRPC or HTTP) Dapr uses to talk to the application (default "http") --app-ssl Enable https when Dapr invokes the application -d, --components-path string The path for components directory (default "/home/ubuntu/.dapr/components") -c, --config string Dapr configuration file (default "/home/ubuntu/.dapr/config.yaml") # dapr程序监听的端口s -G, --dapr-grpc-port int The gRPC port for Dapr to listen on (default -1) -H, --dapr-http-port int The HTTP port for Dapr to listen on (default -1) --enable-profiling Enable pprof profiling via an HTTP endpoint -h, --help Print this help message --log-level string The log verbosity. Valid values are: debug, info, warn, error, fatal, or panic (default "info") -M, --metrics-port int The port of metrics on dapr (default -1) --placement-host-address string The host on which the placement service resides (default "localhost") --profile-port int The port for the profile server to listen on (default -1)
1 2 3
# launch a Dapr sidecar that will listen on port 3500 for a blank application named myapp # 因为没有--config和-d,所以用的就是default的`$HOME/.dapr`下的配置文件。 $ dapr run --app-id myapp --dapr-http-port 3500
1. Run a Redis(TM) pod that you can use as a client: kubectl run --namespace default redis-client --rm --tty -i --restart='Never' \ --env REDIS_PASSWORD=$REDIS_PASSWORD \ --image docker.io/bitnami/redis:6.0.12-debian-10-r3 -- bash
2. Connect using the Redis(TM) CLI: redis-cli -h redis-master -a $REDIS_PASSWORD redis-cli -h redis-slave -a $REDIS_PASSWORD
To connect to your database from outside the cluster execute the following commands:
$ k get pods default redis-headless ClusterIP None <none> 6379/TCP 96s default redis-master ClusterIP 10.107.253.143 <none> 6379/TCP 96s default redis-slave ClusterIP 10.102.228.172 <none> 6379/TCP 96s $ k get secrets NAME TYPE DATA AGE default-token-hnmgm kubernetes.io/service-account-token 3 155m redis Opaque 1 3m4s sh.helm.release.v1.redis.v1 helm.sh/release.v1 1 3m4s
$ k get svc -owide NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 5d13h <none> redis-headless ClusterIP None <none> 6379/TCP 5d10h app=redis,release=redis redis-master ClusterIP 10.107.253.143 <none> 6379/TCP 5d10h app=redis,release=redis,role=master redis-slave ClusterIP 10.102.228.172 <none> 6379/TCP 5d10h app=redis,release=redis,role=slave
$ k get ep NAME ENDPOINTS AGE kubernetes 192.168.49.2:8443 5d13h redis-headless 172.17.0.10:6379,172.17.0.8:6379,172.17.0.9:6379 5d10h redis-master 172.17.0.9:6379 5d10h redis-slave 172.17.0.10:6379,172.17.0.8:6379 5d10h
minikube user
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
$ minikube service nodeapp |-----------|---------|-------------|---------------------------| | NAMESPACE | NAME | TARGET PORT | URL | |-----------|---------|-------------|---------------------------| | default | nodeapp | 80 | http://192.168.49.2:32108 | |-----------|---------|-------------|---------------------------| * Opening service default/nodeapp in default browser... - http://192.168.49.2:32108 # curl localhost:32108不通,因为用的是minikube $ curl http://192.168.49.2:32108/ports {"DAPR_HTTP_PORT":"3500","DAPR_GRPC_PORT":"50001"}