Open Evesy opened 5 years ago
Hello, this is how I'm making the cloud storage provisioning working :
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceInstance
metadata:
name: gcp-iam
namespace: test-deploy
spec:
# This should match with a SERVICE EXTERNAL NAME
# in the list of available services.
clusterServiceClassExternalName: cloud-iam-service-account
# This should match with a PLAN EXTERNAL NAME
# in the list of available service plans.
clusterServicePlanExternalName: beta
parameters:
# The service account name length must be between 6 and 30 characters
accountId: google-cloud-services-sa
displayName: "A service account used to authenticate with all Google Cloud services"
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceBinding
metadata:
name: gcp-iam-binding
namespace: test-deploy
spec:
instanceRef:
name: gcp-iam
secretName: gcp-credentials
This way you will have a kubernetes secret (gcp-credentials) having the gcp credentials (privateKeyData)
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceInstance
metadata:
name: storage-instance
namespace: test-deploy
spec:
clusterServiceClassExternalName: cloud-storage
clusterServicePlanExternalName: beta
parameters:
location: europe-west1
bucketId: bucket-d4dfcc6f-2a3a-4554-9f0c-efc9b5290944
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceBinding
metadata:
name: storage-binding
namespace: test-deploy
spec:
instanceRef:
name: storage-instance
secretName: storage-credentials
parameters:
serviceAccount: google-cloud-services-sa
roles:
- roles/storage.objectCreator
- roles/storage.objectViewer
- roles/storage.admin
volumes:
# Make the 'gcp-credentials' secret available as volume
# 'google-cloud-key'.
- name: google-cloud-key
secret:
secretName: gcp-credentials
volumeMounts:
# Mount the 'google-cloud-key' volume into the container file
# system.
- name: google-cloud-key
mountPath: /var/secrets/google
env:
# Pass the path to the private key JSON file from the mounted volume
# to the environment variable.
# the env var name must be GOOGLE_APPLICATION_CREDENTIALS
- name: "GOOGLE_APPLICATION_CREDENTIALS"
value: /var/secrets/google/privateKeyData
# The two environment variables below come from the 'storage-credentials'
# secret and, together, point at the Cloud Storage Bucket to use.
# choose the env var name that have been used inside the app
- name: "GOOGLE_CLOUD_STORAGE_PROJECT_ID"
valueFrom:
secretKeyRef:
# Use the projectId value from the 'storage-credentials' secret created
# as a result of binding to the Storage service instance.
name: storage-credentials
key: projectId
# choose the env var name that have been used inside the app
- name: "GOOGLE_CLOUD_STORAGE_BUCKET_ID"
valueFrom:
secretKeyRef:
# Use the topicId value from the 'storage-credentials' secret created
# as a result of binding to the Storage service instance.
name: storage-credentials
key: bucketId
Hope it helps.
I've managed to get the GCP broker fully working in other projects, however in this instance while I can create
ServiceInstance
resources OK, attempting to create aServiceBinding
gives forbidden errors (This was a brand new project/cluster)SC version:
0.1.1 darwin/amd64
(Built from master) Kubectl version:(Gcloud config is set with the right project and zone corresponding to the Kubernetes master for good measure.
gcloud auth login
andgcloud auth application-default login
have both been completed.)Reproduction steps:
Create admin role binding:
kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --user=<>@gmail.com
sc check
-- Passedsc install
-- Passedsc add-gcp-broker
:Create a ServiceInstance, for example the below:
Bucket is created in GCP,
svcat get instance
shows it in a Ready stateTry to create a ServiceBinding to that Instance, with the below:
The binding enters a Failed state, describing it shows the below message:
I can see the corresponding error in the API metrics for
google.iam.admin.v1.IAM.GetServiceAccount
but it's not clear to me which permissions are actually incorrectI can see similar errors in the google oauth pod as per #213, unsure if related