Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Add some infrastructure packages #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions infra/configcontroller/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
name: configcontroller
annotations:
config.kubernetes.io/local-config: "true"
info:
description: configcontroller
pipeline:
mutators:
- image: set-name-prefix
- image: generator-configconnectorcontext
- image: bind-gcp-resources
20 changes: 20 additions & 0 deletions infra/configcontroller/bindings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: Namespace
metadata:
name: binding
annotations:
config.kubernetes.io/local-config: "binding"
10 changes: 10 additions & 0 deletions infra/configcontroller/configcontroller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: configcontroller.cnrm.cloud.google.com/v1beta1
kind: ConfigControllerInstance
metadata:
name: packagename
namespace: binding
spec:
location: us-central1
managementConfig:
standardManagementConfig:
masterIPv4CidrBlock: 172.16.0.128/28
13 changes: 13 additions & 0 deletions infra/environment/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
name: environment
annotations:
config.kubernetes.io/local-config: "true"
info:
description: environment
pipeline:
mutators:
- image: set-name-prefix
- image: generator-configconnectorcontext
- image: bind-gcp-resources
1 change: 1 addition & 0 deletions infra/environment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# environment
9 changes: 9 additions & 0 deletions infra/environment/bindings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1
kind: Folder
metadata:
name: environments
namespace: environments-ns
annotations:
config.kubernetes.io/local-config: "binding"
labels:
parent-for: environment
105 changes: 105 additions & 0 deletions infra/environment/kcc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: Namespace
metadata:
name: packagename
annotations:
cnrm.cloud.google.com/project-id: googleprojectid

---

apiVersion: core.cnrm.cloud.google.com/v1beta1
kind: ConfigConnectorContext
metadata:
name: configconnectorcontext.core.cnrm.cloud.google.com
namespace: packagename
spec:
googleServiceAccount: cc-robot@googleprojectid.iam.gserviceaccount.com

---

apiVersion: v1
kind: ServiceAccount
metadata:
name: cnrm-controller-manager-packagename
namespace: cnrm-system
annotations:
config.kubernetes.io/local-config: generated
ownerReferences:
- apiVersion: core.cnrm.cloud.google.com/v1beta1
kind: ConfigConnectorContext
name: configconnectorcontext.core.cnrm.cloud.google.com
namespace: packagename

---

apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMServiceAccount
metadata:
name: packagename-cc-robot
namespace: config-control
annotations:
cnrm.cloud.google.com/project-id: googleprojectid
spec:
displayName: ConfigConnector ServiceAccount
resourceID: cc-robot

---

apiVersion: porch.kpt.dev/v1alpha1
kind: WorkloadIdentityBinding
metadata:
name: packagename-cnrm-controller-manager
namespace: config-control
spec:
resourceRef:
apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMServiceAccount
name: packagename-cc-robot
serviceAccountRef:
name: cnrm-controller-manager-packagename
namespace: cnrm-system

---

apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMPolicyMember
metadata:
name: packagename-cc-robot
namespace: config-control
spec:
memberFrom:
serviceAccountRef:
name: packagename-cc-robot
role: roles/owner
resourceRef:
apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1
kind: Project
name: packagename
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: "packagename-cnrm:cnrm-viewer"
namespace: config-control
subjects:
- kind: ServiceAccount
namespace: cnrm-system
name: cnrm-controller-manager-packagename
roleRef:
kind: ClusterRole
name: cnrm-viewer
apiGroup: rbac.authorization.k8s.io
58 changes: 58 additions & 0 deletions infra/environment/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1
kind: Folder
metadata:
name: packagename
namespace: config-control
spec:
displayName: packagename
folderRef:
name: environments
namepace: environments-ns

---

apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1
kind: Project
metadata:
name: packagename
namespace: config-control
spec:
name: packagename
folderRef:
name: environments
billingAccountRef:
#name: default
# TODO: Is there a BillingAccount ref?
external: 016C6E-5D5038-702920
resourceID: googleprojectid


---

# We need to enable some services so we can enable other services

apiVersion: serviceusage.cnrm.cloud.google.com/v1beta1
kind: Service
metadata:
annotations:
cnrm.cloud.google.com/deletion-policy: "abandon"
name: packagename-serviceusage
namespace: config-control
spec:
resourceID: serviceusage.googleapis.com
projectRef:
name: packagename
32 changes: 32 additions & 0 deletions infra/environment/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMPartialPolicy
metadata:
name: packagename-editors
namespace: config-control
spec:
# TODO: Replace with group?
bindings:
- members:
- member: user:justinsb@google.com
role: roles/editor
- members:
- member: user:justinsb@google.com
role: roles/container.admin
resourceRef:
apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1
kind: Project
name: packagename
32 changes: 32 additions & 0 deletions infra/environment/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: serviceusage.cnrm.cloud.google.com/v1beta1
kind: Service
metadata:
annotations:
cnrm.cloud.google.com/deletion-policy: "abandon"
name: container.googleapis.com
namespace: packagename

---

# Needed to grant GCP IAM permissions on projects
apiVersion: serviceusage.cnrm.cloud.google.com/v1beta1
kind: Service
metadata:
annotations:
cnrm.cloud.google.com/deletion-policy: "abandon"
name: cloudresourcemanager.googleapis.com
namespace: packagename
13 changes: 13 additions & 0 deletions infra/gkecluster/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
name: gkecluster
annotations:
config.kubernetes.io/local-config: "true"
info:
description: sample description
pipeline:
mutators:
- image: set-name-prefix
- image: generator-configconnectorcontext
- image: bind-gcp-resources
1 change: 1 addition & 0 deletions infra/gkecluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# gkecluster
30 changes: 30 additions & 0 deletions infra/gkecluster/bindings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: Namespace
metadata:
name: binding
annotations:
config.kubernetes.io/local-config: "binding"

---

apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1
kind: Project
metadata:
name: binding
namespace: config-control
annotations:
config.kubernetes.io/local-config: "binding"
49 changes: 49 additions & 0 deletions infra/gkecluster/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: container.cnrm.cloud.google.com/v1beta1
kind: ContainerCluster
metadata:
name: packagename
namespace: binding
annotations:
cnrm.cloud.google.com/remove-default-node-pool: "true"
cnrm.cloud.google.com/state-into-spec: absent
spec:
#description: cluster
location: us-central1
enableAutopilot: false
initialNodeCount: 1
releaseChannel:
channel: REGULAR
---
apiVersion: container.cnrm.cloud.google.com/v1beta1
kind: ContainerNodePool
metadata:
name: packagename-default
namespace: binding
spec:
location: us-central1
autoscaling:
minNodeCount: 1
maxNodeCount: 3
nodeConfig:
serviceAccountRef:
name: packagename-gke
management:
autoRepair: true
autoUpgrade: true
clusterRef:
name: packagename
resourceID: default
Loading