Skip to content

Instantly share code, notes, and snippets.

@nakamasato
nakamasato / workflow-dispatch-with-environment-print.yml
Created September 9, 2022 00:08
GitHub Actions - workflow-dispatch-with-environment-print
name: workflow-dispatch-with-environment
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
@nakamasato
nakamasato / workflow-dispatch-with-environment.yml
Created September 8, 2022 23:54
GitHub Actions - workflow-dispatch-with-environment
name: workflow-dispatch-with-environment
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
@nakamasato
nakamasato / release-with-environment.yml
Last active September 8, 2022 23:22
GitHub Actions - example with environment
name: release-with-environment
on:
release:
types: [released]
jobs:
run:
runs-on: ubuntu-latest
environment: production
@nakamasato
nakamasato / bigquery_dataset.tf
Created June 13, 2022 20:58
GCP BigQuery dataset
resource "google_bigquery_dataset" "test_dataset" {
dataset_id = "test_dataset"
friendly_name = "test_dataset"
description = "This is a test dataset"
location = "asia-northeast1"
labels = {
terraform = "true"
}
@nakamasato
nakamasato / service_account.tf
Created June 13, 2022 20:44
GCP service account to grant permission to access BigQuery and GCS
resource "google_service_account" "workbench-default" {
account_id = "workbench-default"
display_name = "Default service account for AI workbench"
}
resource "google_project_iam_binding" "workbench-default-bigquery-data-viwer" {
project = var.project
role = "roles/bigquery.dataViewer"
members = ["serviceAccount:${google_service_account.workbench-default.email}"]
}
@nakamasato
nakamasato / notebook_instance.tf
Created June 13, 2022 20:29
GCP notebook instance terraform file
resource "google_notebooks_instance" "test-notebook" {
name = "test-notebook"
project = "naka-test-notebook"
location = "asia-northeast1-b"
machine_type = "n1-standard-1" // n1-standard-1 $41.01 monthly estimate
install_gpu_driver = false
instance_owners = ["naka@gmail.com"]
vm_image { // https://cloud.google.com/vertex-ai/docs/workbench/user-managed/images
project = "deeplearning-platform-release"
image_family = "common-cpu-notebooks"
@nakamasato
nakamasato / google_project_iam_config.tf
Last active April 30, 2022 00:59
Configure Data Access Audit Log with Terraform
resource "google_project_iam_audit_config" "all-services" {
project = "<your project>"
service = "allServices"
audit_log_config {
log_type = "ADMIN_READ"
}
audit_log_config {
log_type = "DATA_READ"
}
audit_log_config {
...
import (
appsv1 "k8s.io/api/apps/v1" // added
corev1 "k8s.io/api/core/v1" // added
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" // added
"k8s.io/apimachinery/pkg/types" // added
"context"
func (r *MemcachedReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := r.Log.WithValues("memcached", req.NamespacedName)
// 1. Fetch the Memcached instance
memcached := &cachev1alpha1.Memcached{}
err := r.Get(ctx, req.NamespacedName, memcached)
if err != nil {
if errors.IsNotFound(err) {
log.Info("1. Fetch the Memcached instance. Memcached resource not found. Ignoring since object must be deleted")
return ctrl.Result{}, nil
import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"reflect" //added
"context"