Commit cb3f9f1b authored by Marc Bärtschi's avatar Marc Bärtschi

add ci

parent ed3178f3
build-frontend:
stage: build
script: [""]
variables:
BUILD_DIR: frontend/
BUILD_FROM_ROOT: "true"
tags:
- docker
build-backend:
stage: build
script: [""]
variables:
BUILD_DIR: backend/
BUILD_FROM_ROOT: "true"
tags:
- docker
\ No newline at end of file
FROM golang:1.12
ENV CGO_ENABLED 0
WORKDIR $GOPATH/src/git.dolansoft.org/marc/dns/backend
COPY backend/ .
RUN go get . && go install --ldflags="-w -s" .
FROM scratch
COPY --from=0 /go/bin/backend /backend
CMD ["/backend"]
......@@ -2,11 +2,13 @@ package main
import (
"context"
"crypto/tls"
"crypto/x509"
"flag"
"fmt"
"io/ioutil"
"log"
"net"
"path/filepath"
"sync"
"time"
......@@ -14,10 +16,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/homedir"
pb "git.dolansoft.org/marc/dns/proto"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
type dnsServer struct {
......@@ -26,16 +28,30 @@ type dnsServer struct {
}
func main() {
var kubeconfig *string
if home := homedir.HomeDir(); home != "" {
kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file")
} else {
kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
}
kubeconfig := flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
flag.Parse()
log.SetFlags(log.LstdFlags | log.Lshortfile)
certificate, err := tls.LoadX509KeyPair("/sec/tls/tls.crt", "/sec/tls/tls.key")
if err != nil {
log.Fatalf("could not load server key pair: %s", err)
}
// Create a certificate pool from the certificate authority
certPool := x509.NewCertPool()
ca, err := ioutil.ReadFile("/sec/pki/ca.pem")
if err != nil {
log.Fatalf("could not read ca certificate: %s", err)
}
// Append the client certificates from the CA
if ok := certPool.AppendCertsFromPEM(ca); !ok {
log.Fatal("failed to append client certs")
}
config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
if err != nil {
log.Fatal(err)
......@@ -45,7 +61,7 @@ func main() {
log.Fatal(err)
}
deploymentsClient := clientset.ExtensionsV1beta1().Ingresses(apiv1.NamespaceAll)
deploymentsClient := clientset.NetworkingV1beta1().Ingresses(apiv1.NamespaceDefault)
fmt.Printf("Listing Ingresses in namespace %q:\n", apiv1.NamespaceAll)
list, err := deploymentsClient.List(metav1.ListOptions{})
......@@ -97,8 +113,14 @@ func main() {
log.Fatalf("failed to listen: %v", err)
}
// create a gRPC server object
grpcServer := grpc.NewServer()
creds := credentials.NewTLS(&tls.Config{
ClientAuth: tls.RequireAndVerifyClientCert,
Certificates: []tls.Certificate{certificate},
ClientCAs: certPool,
})
// Create the gRPC server with the credentials
grpcServer := grpc.NewServer(grpc.Creds(creds))
// attach the service to the server
......
......@@ -20,7 +20,7 @@ func main() {
// GRPC Backend Service
// Open a Connection
var clientConn *grpc.ClientConn
clientConn, err := grpc.Dial(":8520", grpc.WithInsecure())
clientConn, err := grpc.Dial("212.51.131.33:8520", grpc.WithInsecure())
if err != nil {
log.Fatalf("did not connect: %s", err)
}
......@@ -31,8 +31,8 @@ func main() {
// Create Server
server := &Server{
host: "127.0.0.1",
port: 5001,
host: "0.0.0.0",
port: 51,
rTimeout: 5 * time.Second,
wTimeout: 5 * time.Second,
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment