Skip to content

Instantly share code, notes, and snippets.

View alaypatel07's full-sized avatar

Alay Patel alaypatel07

  • Raleigh, North Carolina
View GitHub Profile
package main
import (
"context"
"crypto/tls"
"crypto/x509"
"flag"
"fmt"
"io/ioutil"
"log"
package main
import (
"context"
"fmt"
"log"
"os"
"text/tabwriter"
"github.com/spf13/pflag"
@alaypatel07
alaypatel07 / avoid-conflicts-poc.go
Last active July 19, 2024 19:24
avoiding 409 conflict errors with strategic merge patch
package main
import (
"context"
"encoding/json"
"fmt"
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"
package main
import (
"fmt"
"k8s.io/test-infra/prow/apis/prowjobs/v1"
"sigs.k8s.io/yaml"
)
func main() {
@alaypatel07
alaypatel07 / rsync-stunnel-server-setup.yaml
Last active November 29, 2021 18:45
rsync stunnel manual setup with nginx ingress
apiVersion: v1
kind: Pod
metadata:
labels:
app: crane2
name: rsync-server
namespace: default
spec:
containers:
- command:
/*
Copyright 2019 Red Hat Inc.
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
export RESOURCE="migrationcontrollers"
export NAMESPACE="openshift-migration"
if [ -z "$1" ]; then
export USER="bob"
else
export USER=$1
fi
if [ -z "$2" ]; then
htpasswd -c -B -b users.htpasswd bob bob
oc create secret generic htpass-secret --from-file=htpasswd=./users.htpasswd -n openshift-config
oc patch oauth cluster --type='json' -p '[ { "op": "replace", "path": "/spec", "value": {"identityProviders": [{"htpasswd": {"fileData": {"name": "htpass-secret"}}, "mappingMethod": "claim", "name": "bob_httpassd_provider", "type": "HTPasswd"}]}}]'
oc login -u bob -p bob
oc new-project bob-destination
oc login -u kubeadmin -p $KUBEADMIN_PASSWORD
cat <<EOF | oc create -f -
apiVersion: migration.openshift.io/v1alpha1
kind: MigrationTenant
metadata:
func (r *ReconcileMigToken) Reconcile(request reconcile.Request) (reconcile.Result, error) {
var err error
log.Reset()
token := &migapi.MigToken{}
// prefer a separate function call instead of defer func() {}()
// two advantages:
// 1. defers are hard(er) to debug/reason about than normal calls
// 2. with normal function we can have a matching else condition
oc create namespace openshift-migration
#create service for mongo-db
cat <<EOF | oc create -f -
kind: Service
apiVersion: v1
metadata:
name: mig-operator-noobaa-db
namespace: openshift-migration
labels: