Skip to content

Instantly share code, notes, and snippets.

View akash-gautam's full-sized avatar

Akash Gautam akash-gautam

View GitHub Profile
@akash-gautam
akash-gautam / sslconfig-crd.yaml
Created August 21, 2018 06:36
sslconfig-crd.yaml contains the definition for custom resource
apiVersion: "apiextensions.k8s.io/v1beta1"
kind: "CustomResourceDefinition"
metadata:
name: "sslconfigs.blog.velotio.com"
spec:
group: "blog.velotio.com"
version: "v1alpha1"
scope: "Namespaced"
names:
plural: "sslconfigs"
@akash-gautam
akash-gautam / sslconfig-obj.yaml
Last active August 21, 2018 06:56
sslconfig-obj.yaml defines an object of sslconfig type
apiVersion: "blog.velotio.com/v1alpha1"
kind: "SslConfig"
metadata:
name: "sslconfig-velotio.com"
spec:
cert: "my cert file"
key : "my private key"
domain: "*.velotio.com"
provider: "digicert"
@akash-gautam
akash-gautam / createcrd.go
Created August 21, 2018 07:40
createcrd.go contains the function which creates the custom resource definition for our object
package v1alpha1
import (
"reflect"
apiextensionv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
apiextension "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
apierrors "k8s.io/apimachinery/pkg/api/errors"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@akash-gautam
akash-gautam / register.go
Created August 21, 2018 07:47
register.go contains the function which creates a client which is aware of our crd
package v1alpha1
import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/client-go/rest"
)
@akash-gautam
akash-gautam / sslconfig.go
Created August 21, 2018 10:37
sslconfig.go contains the sslconfig interface,client and methods for accessing sslconfig objects using the client
package v1alpha1
import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/rest"
)
func (c *SslConfigV1Alpha1Client) SslConfigs(namespace string) SslConfigInterface {
return &sslConfigclient{
client: c.restClient,
@akash-gautam
akash-gautam / type.go
Created August 21, 2018 10:38
type.go contains the structure of objects of type sslconfig
package v1alpha1
import meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
type SslConfig struct {
meta_v1.TypeMeta `json:",inline"`
meta_v1.ObjectMeta `json:"metadata"`
Spec SslConfigSpec `json:"spec"`
Status SslConfigStatus `json:"status,omitempty"`
}
package main
import (
"flag"
"fmt"
"time"
"blog.velotio.com/crd-blog/v1alpha1"
"github.com/golang/glog"
apiextension "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
apiVersion: v1
kind: Service
metadata:
name: mongodb-service
spec:
ports:
- port: 27017
targetPort: 27017
protocol: TCP
name: mongodbport
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: mongodb
spec:
template:
metadata:
labels:
app: mongodb
spec:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: test-app
spec:
replicas: 1
template:
metadata:
labels:
app: test-app