I'm using node js & am wanting to upload files to a bucket of mine. I've setup the secret:
NAME TYPE DATA AGE
cloudsql-oauth-credentials Opaque 1 5d
default-token-dv9kj kubernetes.io/service-account-token 3 5d
The service_account does have access to my google cloud storage API as I've set that up already & tested it locally (on my own computer). I'm unsure how I can reference the location of the service account json file?!
Here is my volumes mount:
"volumes": [{
"name": "cloudsql-oauth-credentials",
"secret": {
"secretName": "cloudsql-oauth-credentials"
}
}
Here is the code where I'm setting up the google-cloud storage variable:
var gcs = require('#google-cloud/storage')({
projectId: 'projectID-38838',
keyFilename: process.env.NODE_ENV == 'production'
? JSON.parse(process.env.CREDENTIALS_JSON) // Parsing js doesn't work
: '/Users/james/auth/projectID-38838.json' // This works locally
});
var bucket = gcs.bucket('bucket-name');
Now if I want to use this inside my docker container on kubernetes, I'll have to reference the json file location...But I don't know where it is?!
I've tried setting the Credentials file as an environment variable, but I cannot parse a js object to the keyFilename object. I have to parse a file location. I set the env variable up like so:
{
"name": "CREDENTIALS_JSON",
"valueFrom": {
"secretKeyRef": {
"name": "cloudsql-oauth-credentials",
"key": "credentials.json"
}
}
},
How can I reference the location of the service_account json file inside my kubernetes pod?!
Look here in the section Using Secrets as Files from a Pod.
Basically, you need to specify two things when mounting a secret volume. The bit that you have + some extra info. There might be some redundancies with the key but this is what I do and it works.
When creating a secret, create it with a key:
kubectl create secret generic cloudsql-oauth-credentials --from-file=creds=path/to/json
Then
"volumes": [{
"name": "cloudsql-oauth-credentials",
"secret": {
"secretName": "cloudsql-oauth-credentials"
"items": [{
"key": "creds",
"path": "cloudsql-oauth-credentials.json"
}]
}
}
But then also specify where it goes in the container definiton (in Pod, Deployment, Replication Controller - whatever you use):
"spec": {
"containers": [{
"name": "mypod",
"image": "myimage",
"volumeMounts": [{
"name": "cloudsql-oauth-credentials",
"mountPath": "/etc/credentials",
"readOnly": true
}]
}],
The file will be mapped to /etc/credentials/cloudsql-oauth-credentials.json.
Related
Created Google Smart Home Action.
Implemented device with:
a. deviceType = action.devices.types.SETTOP
b. deviceTrait = action.devices.traits.Channel
Device is successfully discovered and added to Google Home App's Homegraph.
User sends command: "Ok Google, change to ESPN"
Receives the following json in fulfillment URL:
{
"requestId": "[RequestId GUID]",
"inputs": [{
"intent": "action.devices.EXECUTE",
"payload": {
"commands": [{
"devices": [{
"id": "[SettopBox device Id]"
}],
"execution": [{
"command": "action.devices.commands.selectChannel",
"params": {
"channelCode": "espn",
"channelName": "ESPN",
"channelNumber": "206"
}
}]
}]
}
}]
}
Questions:
How does Google Smart Home determine the "channelNumber" value for "ESPN"? The user's command was "Ok Google, change to "ESPN". This does not contain any information about the channel number.
If a provider was set automatically, is there a setting in Google Home or Google Assistant to change this provider?
The number of a channel for the Channel trait is provided in the SYNC request along with any relevant labels.
{
"availableChannels": [
{
"key": "ktvu2",
"names": [
"Fox",
"KTVU"
],
"number": "2"
},
{
"key": "abc1",
"names": [
"ABC",
"ABC East"
],
"number": "4-11"
}
]
}
As shown in the snippet, the channel number comes from the service. This may be up to the developer of the integration how these numbers may be determined, whether from a cable provider or over-the-air. The field is optional, so a service without channel numbers may still work by saying its name.
How are you.
I am deploying go backend api to ecs using docker.
And I am using circle ci for it.
I need to set database config environment variables to run backend api, but I don't know how to set that info in circle ci.
I am initializing aws resource using terraform, do I need to set db config environment variables in terraform? or can I set it on circle ci config.yml?
Thanks
You can define environment variables in the task definition so this will be available for your docker container in ECS.
resource "aws_ecs_task_definition" "backend-app" {
family = "backend"
container_definitions = <<EOF
[
{
"portMappings": [
{
"hostPort": 80,
"protocol": "tcp",
"containerPort": 3000
}
],
"environment":
[
{
"name": "NODE_ENV",
"value":"production"
},
{
"name": "DB_HOST",
"value": "HOST_ADDRESS"
},
{
"name": "DB_PASS",
"value": "DB_PASSWORD"
}
],
"cpu": 1000,
"memory": 1000,
"image": "***.dkr.ecr.us-west-2.amazonaws.com/backend:latest",
"name": "backend",
}
]
EOF
}
I'm trying to build a Logic Apps Custom Connector that can update a JIRA issue (a feature not currently available in the prebuilt connector).
Here is a cURL example from the JIRA documentation for this request
curl -D- -u fred:fred -X PUT --data {see below} -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/issue/QA-31
{
"fields": {
"assignee":{"name":"harry"}
}
}
The QA-31 value is the unique identifier that I want to make a variable. Using Postman I set that as an Environment variable and successfully ran the request. When I uploaded the Postman collection to my custom connector 'QA-31' value wasn't available as a path variable
Then I tried editing the custom connector directly. In the Import Sample menu I replaced 'QA-31' in the URL with '{issueKey}'. This created a path variable but it also prefixed the url with '/en-us/widgets/manage'; which I don't want
Here is a picture of the problem
So there are a couple questions here:
Why is my path variable in Postman not being picked up in the custom connector while other requests from that collection were working fine
Why is my URL being prefixed with '/en-us/widgets/manage' when add a path variable in the 'Import from Sample' menu
Thanks!
Inside the Logic Apps Custom Connector Editor you may define path variables by enclosing the variable inside brackets (e.g. https://api.library.com/[method}/). This can be done manually during the "Definition" step of creating/editing your custom connector. However, the drawback is that you must use the "Import from sample" feature which requires you to manually rewrite the particular request.
To answer your question we can define the path variables in PostMan and then run the V1 export.
You can define a path variable in a Postman request by prepending a ':' to the variable name like so, https://api.library.com/:method/. This will add the key (method) and the optional value to the request parameters field.
When you export as a Postman V1 collection the resulting JSON code looks like,
{
"id": "fc10d942-f460-4fbf-abb6-36943a112bf6",
"name": "Custom Method Demo",
"description": "",
"auth": null,
"events": null,
"variables": [],
"order": [
"becb5ff8-6d31-48ee-be3d-8c70777d60aa"
],
"folders_order": [],
"folders": [],
"requests": [
{
"id": "becb5ff8-6d31-48ee-be3d-8c70777d60aa",
"name": "Custom Request Method",
"url": "https://api.library.com/:method",
"description": "Use a path variable to define a custom method.",
"data": null,
"dataMode": "params",
"headerData": [],
"method": "GET",
"pathVariableData": [
{
"key": "method",
"value": ""
}
],
"queryParams": [],
"auth": {
"type": "noauth"
},
"events": [
{
"listen": "prerequest",
"script": {
"id": "b7b91243-0c58-4dc6-b3ee-4fb4ffc604db",
"type": "text/javascript",
"exec": [
""
]
}
}
],
"folder": null,
"headers": "",
"pathVariables": {
"method": ""
}
}
]}
Notice the "pathVariables" field which corresponds to our custom path variable.
Now we can import this into our Logic App and the path variable is properly interpreted as described in the first paragraph.
Hope that helps.
Hello i want to configure my PWA app.
My app works fine except dynamic content api. When online it working fine but when i go offline i get status 503 from serviceWorker.
My config file:
ngsw-manifest.json
{
"dynamic": {
"group": [{
"name": "api",
"urls": {
"https:url": {
"match": "prefix"
}
},
"cache": {
"optimizeFor": "freshness",
"maxAgeMs": 3600000,
"maxEntries": 20,
"strategy": "lru"
}
}]
},
"external": {
"urls": [{
"url": "https://fonts.googleapis.com/icon?family=Material+Icons"
}]
}
}
If you are hosting your app on Firebase you might want to look into using the new Firestore database. It's is designed for offline data. Firebase had issues with PWAs in Offline Mode. Also, the core of PWAs (ServiceWorker) has been rewritten in Angular 5.
I have seen this in the Google API's. Is it possible for Cloud Endpoints as well?
https://developers.google.com/apis-explorer/#p/adexchangebuyer/v1.2/adexchangebuyer.accounts.get
It's totally possible. We've had some StackOverflow posts about monkey patching and this would be another prime example.
For example:
How do I specify my own icons so they show up in a Google Endpoints API discovery document?
For this case, the content served at /_ah/spi/BackendService.getApiConfigs contains your API config and the "description" you want here is for a "parameter".
So for example in the method
#endpoints.method(MySchema, MySchema,
path='myschema/{strField}', name='myschema.echo')
def MySchemaEcho(self, request):
return request
the field strField is a path "parameter" and so in the API config we would see
{
...
"methods": {
"myapi.myschema.echo": {
...
"request": {
...
"parameters": {
"strField": {
"required": true,
"type": "string"
}
}
},
...
}
...
}
}
To get your description in there you would need to add it to the dictionary listed under strField so that it reads
"strField": {
"required": true,
"type": "string",
"description": "Most important field that ever was."
}