-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: Add quickstart guide to README (#126)
Adds quickstart instructions to the README. This tells the user how to follow the existing Cloud SQL Quickstart on GKE guide, adding a few extra steps in the middle, to try out the operator.
- Loading branch information
Showing
5 changed files
with
354 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Development | ||
|
||
# How this project was created | ||
This project was initially scaffolded by `kubebuilder` 3.6.0. These are the | ||
commands initially used to set up the project. | ||
|
||
``` | ||
# Get the kubebuilder binary | ||
mkdir -p .bin | ||
curl -L -o .bin/kubebuilder "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v3.6.0/kubebuilder_$(go env GOOS)_$(go env GOARCH)" | ||
chmod a+x .bin/kubebuilder | ||
# Clean up the root dir for kubebuilder | ||
rm -rf Makefile main.go go.mod go.sum cover.out | ||
mkdir -p .bin/tmp/ | ||
mv docs .bin/tmp/ | ||
mv version.txt .bin/tmp/ | ||
rm -rf bin | ||
.bin/kubebuilder init --owner "Google LLC" --project-name "cloud-sql-proxy-operator" --domain cloud.google.com --repo github.com/GoogleCloudPlatform/cloud-sql-proxy-operator | ||
mv .bin/tmp/* . | ||
``` | ||
|
||
Then, to create the CRD for Workload | ||
``` | ||
.bin/kubebuilder create api --group cloudsql --version v1alpha1 --kind AuthProxyWorkload --controller --resource --force | ||
.bin/kubebuilder create webhook --group cloudsql --version v1alpha1 --kind AuthProxyWorkload --defaulting --programmatic-validation | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# 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. | ||
|
||
### | ||
# This example demonstrates how to use environment variables set by the | ||
# Cloud SQL Proxy Operator to connect to your database. | ||
|
||
## | ||
# Create an AuthProxyWorkload to hold the configuration for your | ||
# Cloud SQL Proxy containers. | ||
|
||
apiVersion: cloudsql.cloud.google.com/v1alpha1 | ||
kind: AuthProxyWorkload | ||
metadata: | ||
name: authproxyworkload-sample | ||
spec: | ||
workloadSelector: | ||
kind: "Deployment" # Applies to a "Deployment" | ||
name: "gke-cloud-sql-app" # named 'gke-cloud-sql-app' | ||
instances: | ||
- connectionString: "my-project:us-central1:instance" # from your Cloud SQL Database instance | ||
portEnvName: "DB_PORT" # Will set an env var named 'DB_PORT' to the database port | ||
hostEnvName: "DB_HOST" # Will set an env var named 'DB_HOST' to the proxy's host, 127.0.0.1 | ||
--- | ||
## | ||
# Put the database name, username, and password into a kubernetes secret | ||
# Update the values below as needed for your environment | ||
# | ||
# WARNING: Do not store passwords in a source code file. It is a bad | ||
# way to keep your secrets safe. | ||
# | ||
# Instead, use kubectl to create the secret using an interactive command | ||
# so that your password is not stored in your source code. | ||
# | ||
# kubectl create secret generic gke-cloud-sql-operator-demo \ | ||
# --from-literal=DB_NAME=your_db_name \ | ||
# --from-literal=DB_USER=your_db_user \ | ||
# --from-literal=DB_PASS=your_db_password | ||
# | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: gke-cloud-sql-operator-demo | ||
type: Opaque | ||
data: | ||
DB_PASS: cGFzc3dvcmQ= # "password" | ||
DB_NAME: cG9zdGdyZXM= # "postgres" | ||
DB_USER: dGVzdHVzZXI= # "testuser" | ||
--- | ||
## | ||
# Create a deployment for your application that uses environment variables | ||
# set by the proxy to connect to the database. | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: gke-cloud-sql-app | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: gke-cloud-sql-app | ||
template: | ||
metadata: | ||
labels: | ||
app: gke-cloud-sql-app | ||
spec: | ||
containers: | ||
- name: gke-cloud-sql-app | ||
image: postgres | ||
livenessProbe: | ||
initialDelaySeconds: 60 | ||
periodSeconds: 30 | ||
failureThreshold: 3 | ||
exec: | ||
command: ["/bin/sh", "-c", "psql --host=$DB_HOST --port=$DB_PORT --username=$DB_USER '--command=select 1' --echo-queries --dbname=$DB_NAME"] | ||
command: | ||
- "/bin/sh" | ||
- "-e" | ||
- "-c" | ||
- "sleep 10 ; psql --host=$DB_HOST --port=$DB_PORT --username=$DB_USER '--command=select 1' --echo-queries --dbname=$DB_NAME ; sleep 3600" | ||
env: | ||
- name: DB_HOST | ||
value: "set-by-operator" | ||
- name: DB_PORT | ||
value: "set-by-operator" | ||
- name: DB_USER | ||
valueFrom: | ||
secretKeyRef: | ||
name: gke-cloud-sql-operator-demo | ||
key: DB_USER | ||
- name: DB_USER | ||
valueFrom: | ||
secretKeyRef: | ||
name: gke-cloud-sql-operator-demo | ||
key: DB_USER | ||
- name: PGPASSWORD # The env name PGPASSWORD is specific to the psql command. | ||
valueFrom: | ||
secretKeyRef: | ||
name: gke-cloud-sql-operator-demo | ||
key: DB_PASS | ||
- name: DB_NAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: gke-cloud-sql-operator-demo | ||
key: DB_NAME |
Oops, something went wrong.