By default, a message that cannot be delivered within the maximum retention time of 7 days is deleted and is no longer accessible. This typically happens when subscribers do not keep up with the flow of messages. Note that you can configure message retention duration (the range is from 10 minutes to 7 days).
# Requests is already installed, no need to add it to requirements.txt import requests
def calling_function(request): # Make sure to replace variables with appropriate values receiving_function_url = 'https://us-central1-graphical-bus-248617.cloudfunctions.net/xxx-slave '
# Set up metadata server request # See https://cloud.google.com/compute/docs/instances/verifying-instance-identity#request_signature metadata_server_token_url = 'http://metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience='
# Provide the token in the request to the receiving function receiving_function_headers = {'Authorization': f'bearer {jwt}'} function_response = requests.get(receiving_function_url, headers=receiving_function_headers)
return function_response.content
完成上面两部后,xxx-slave function就可以在被认证的情况下调用了。
这里还需要注意的是要将Cloud Functions Invoker 中的 all user移除,不然xxx-slave方法还是公开的,操作步骤:
apiVersion: certmanager.k8s.io/v1alpha1 kind: ClusterIssuer metadata: name: letsencrypt-prod spec: acme: # The ACME server URL server: https://acme-v02.api.letsencrypt.org/directory # Email address used for ACME registration email: youremail@yourdomain.com # Name of a secret used to store the ACME account private key privateKeySecretRef: name: letsencrypt-prod # Enable the HTTP-01 challenge provider http01: {}
配置DNS
获取nginx-ingress-controller的IP
1
kubectl get svc -n default
output:
1 2 3 4
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.64.0.1 <none> 443/TCP 64m nginx-ingress-controller LoadBalancer 10.64.11.170 35.188.93.188 80:30393/TCP,443:30515/TCP 59m nginx-ingress-default-backend ClusterIP 10.64.5.162 <none> 80/TCP 59m
apiVersion: extensions/v1beta1 kind: Ingress metadata: name: name-virtual-host-ingress annotations: kubernetes.io/ingress.class: nginx certmanager.k8s.io/cluster-issuer: letsencrypt-prod nginx.ingress.kubernetes.io/ssl-redirect: "true" spec: tls: # < placing a host in the TLS config will indicate a cert should be created - hosts: - demo.w2x.me secretName: letsencrypt-prod rules: