Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GKE Security Features to Deployment Manager config #879

Merged
merged 4 commits into from May 30, 2018
Merged

Add GKE Security Features to Deployment Manager config #879

merged 4 commits into from May 30, 2018

Conversation

ankushagarwal
Copy link
Contributor

@ankushagarwal ankushagarwal commented May 25, 2018

Add option for

  • Private Clusters
  • Separate Service Account
  • masterIpv4CidrBlock
  • Pod Security Policy
  • Secure Node Metadata
  • Authorized Networks for k8s Master
  • Reduce oauth scopes for worker nodes and replace it with gke-default

/cc @jlewi @kunmingg


This change is Reviewable

@ankushagarwal ankushagarwal changed the title Add GKE Security Features to bootstrapper Add GKE Security Features to Deployment Manager config May 25, 2018
# kubectl at that point. So we put all resources in a single deployment.
- name: kubeflow
type: cluster.jinja
properties:
zone: us-east1-d
# Set this to v1beta1 to use beta features such as private clusters,
apiVersion: v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1beta1 or v1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to set a default value of v1. If the end-user wants to leverage beta features, they can set this to v1beta1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the GKE API version? Should we call it gkeApiVersion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Updated

nodeConfig:
machineType: n1-standard-1
serviceAccount: {{ properties['serviceAccountName'] }}@{{ env['project'] }}.iam.gserviceaccount.com
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to use the service account as the VM service account? I think a better practice is to move in the direction of creating secrets containing service account keys. This way we can provide finer grained permissions then what we get from node service accounts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This service account will not be used by pods. This service account is intended to replace the default compute engine service account which has Project Editor Role. We will be using secrets and service account keys to give access to individual pods.

@@ -72,59 +83,85 @@ resources:
monitoringService: monitoring.googleapis.com/kubernetes
{% else %}
initialClusterVersion: 1.9.6-gke.1
{% endif %}
{% endif %}
podSecurityPolicyConfig:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make all the security parameters fields in a dictionary "securityFeatures" just to make the properties a little bit more human readable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jlewi
Copy link
Contributor

jlewi commented May 26, 2018

Looks like the test failed because you need the IAM API; you just need to add

- name: iam-api
  action: 'gcp-types/servicemanagement-v1:servicemanagement.services.enable'
  properties: 
    consumerId: {{ 'project:' + env['project'] }}
    serviceName: iam.googleapis.com

and then make sure the patch step depends on that step.

@jlewi
Copy link
Contributor

jlewi commented May 26, 2018

Same error

RROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1527296670560-56d117783ef01-9cc0d413-1104737f]: errors:
- code: RESOURCE_ERROR
 location: /deployments/z79-6e2d4ba-1689-1b9d/resources/kubeflow-service-account
 message: '{"ResourceType":"iam.v1.serviceAccount","ResourceErrorCode":"403","ResourceErrorMessage":{"code":403,"message":"Identity
   and Access Management (IAM) API has not been used in project 593963025935 before
   or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/iam.googleapis.com/overview?project=593963025935
   then retry. If you enabled this API recently, wait a few minutes for the action
   to propagate to our systems and retry.","status":"PERMISSION_DENIED","details":[{"@type":"type.googleapis.com/google.rpc.Help","links":[{"description":
"Google
   developers console API activation","url":"https://console.developers.google.com/apis/api/iam.googleapis.com/overview?project=593963025935"}]}],"statusM
essage":"Forbidden","requestPath":"https://iam.googleapis.com/v1/projects/kubeflow-ci/serviceAccounts","httpMethod":"POST"}}'

/test all

Ankush Agarwal added 2 commits May 29, 2018 11:29
Use gke-default oauth scopes

Update to gkeApiVersion

Add securityConfig

Enable iam api in dm
- https://www.googleapis.com/auth/logging.write
- https://www.googleapis.com/auth/monitoring
- https://www.googleapis.com/auth/service.management.readonly
- https://www.googleapis.com/auth/servicecontrol
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging and monitoring make sense for the logging and monitoring agents but what about the others?

I assume devstorage is for GCR?

Why do we need service.management, servicecontrol, and trace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I substituted gke-default [1] with the actual scopes. I will reduce the scopes.

[1] https://cloud.google.com/sdk/gcloud/reference/container/clusters/create

@@ -139,7 +144,12 @@ resources:
machineType: n1-standard-8
serviceAccount: {{ properties['vmServiceAccountName'] }}@{{ env['project'] }}.iam.gserviceaccount.com
oauthScopes:
- gke-default
- https://www.googleapis.com/auth/devstorage.read_only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we define a variable and reuse it to avoid code duplication and ensure they stay in sync?

@ankushagarwal
Copy link
Contributor Author

@jlewi This is ready for review

@jlewi
Copy link
Contributor

jlewi commented May 30, 2018

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jlewi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit f25dd9e into kubeflow:master May 30, 2018
@ankushagarwal ankushagarwal deleted the securestuff branch June 1, 2018 22:46
saffaalvi pushed a commit to StatCan/kubeflow that referenced this pull request Feb 11, 2021
* Add GKE Security Features to bootstrapper

Use gke-default oauth scopes

Update to gkeApiVersion

Add securityConfig

Enable iam api in dm

* Add oauth scopes manually. gke-default does not work

* Fix oauthscopes

* Add PodSecurityPolicy only to v1beta1
yanniszark pushed a commit to arrikto/kubeflow that referenced this pull request Feb 15, 2021
* feat: Add event when the reconcile is failed

Signed-off-by: Ce Gao <gaoce@caicloud.io>

* fix: Use format

Signed-off-by: Ce Gao <gaoce@caicloud.io>
surajkota pushed a commit to surajkota/kubeflow that referenced this pull request Jun 13, 2022
…ad (kubeflow#879)

* image gcr.io/kubeflow-images-public/notebook-controller:vmaster-g0cb184ad
* Image built from kubeflow/kubeflow@0cb184ad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants