Skip to content

Instantly share code, notes, and snippets.

View developer-guy's full-sized avatar
🐾
Every artifact can be verifiably traced to Source Code and Hardware

Batuhan Apaydın developer-guy

🐾
Every artifact can be verifiably traced to Source Code and Hardware
View GitHub Profile
@developer-guy
developer-guy / kubernetes_add_service_account_kubeconfig.sh
Created January 14, 2020 05:37 — forked from innovia/kubernetes_add_service_account_kubeconfig.sh
Create a service account and generate a kubeconfig file for it - this will also set the default namespace for the user
#!/bin/bash
set -e
set -o pipefail
# Add user to k8s using service account, no RBAC (must create RBAC after this script)
if [[ -z "$1" ]] || [[ -z "$2" ]]; then
echo "usage: $0 <service_account_name> <namespace>"
exit 1
fi
package deployment
import (
"fmt"
"strings"
"terratest-demo/util"
"testing"
"time"
httpHelper "github.com/gruntwork-io/terratest/modules/http-helper"
package helm
import (
"github.com/gruntwork-io/terratest/modules/helm"
"github.com/stretchr/testify/suite"
coreV1 "k8s.io/api/core/v1"
"testing"
)
type HelmRenderingSuite struct {
package helm
import (
"fmt"
"github.com/gruntwork-io/terratest/modules/helm"
httpHelper "github.com/gruntwork-io/terratest/modules/http-helper"
"github.com/gruntwork-io/terratest/modules/k8s"
"github.com/gruntwork-io/terratest/modules/random"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
package main
import (
http_helper "github.com/gruntwork-io/terratest/modules/http-helper"
"github.com/gruntwork-io/terratest/modules/terraform"
"testing"
"time"
)
func TestWebServer(t *testing.T) {
@developer-guy
developer-guy / install.sh
Last active April 3, 2020 16:08
kubeval jsonschemas installation
#!/usr/bin/bash
# Don't forget to change your schemas location.
declare -a supported_versions
supported_versions=(v1.17.0 v1.16.0 v1.15.0)
EXTRACT_COMMAND="mkdir -p ~/.kubeval/schemas && \
curl https://codeload.github.com/instrumenta/kubernetes-json-schema/tar.gz/master | \
tar -C ~/.kubeval/schemas --strip-components=1 -xzvf - "
for sv in "${supported_versions[@]}"
do
echo "Supported version: $sv"
@developer-guy
developer-guy / netshoot-deployment.yaml
Created April 3, 2020 14:36
netshoot deployment manifest
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: netshoot
name: netshoot
spec:
replicas: 2
selector:
matchLabels:
#Then the MutatingAdmissionWebhook observes the requests to apiserver and intercepts requests matching the rules in admission webhooks and calls them in parallel.
# For each request to the apiserver, the MutatingAdmissionWebhook sends an admissionReview(API for reference) to the relevant webhook admission server. The webhook admission server gathers information like object, oldobject, and userInfo from admissionReview, and sends back a admissionReview response including AdmissionResponse whose Allowed and Result fields are filled with the admission decision and optional Patch to mutate the resoures.
# MutatingAdmissionWebhook needs to be registered in the apiserver by providing MutatingWebhookConfiguration.
# During the registration process, MutatingAdmissionWebhook states:
# - How to connect to the webhook admission server
# - How to verify the webhook admission server
# - The URL path of the webhook admission server
# - Rules defining which resource and what action it handles
# -How unrecogni
#!/usr/bin/env bash
PROJECT=sidecar-injector
: ${1?'missing key directory'}
key_dir="$1"
chmod 0700 "$key_dir"
cd "$key_dir"
apiVersion: v1
kind: Service
metadata:
name: sidecar-injector-service
namespace: platform
spec:
selector:
app: sidecar-injector-server
ports:
- port: 443