diff options
author | Jan Malkiewicz <jan.malkiewicz@nokia.com> | 2020-09-30 11:29:19 +0200 |
---|---|---|
committer | Jan Malkiewicz <jan.malkiewicz@nokia.com> | 2020-09-30 13:02:59 +0200 |
commit | 93fdf569416a631dfc9aa0f5e0173c70a70d931a (patch) | |
tree | c4c07c6561ad4dd1d0acc3becb629c5c6411d9e3 /certServiceK8sExternalProvider | |
parent | 8dd3ea1c8851249904cf6e6000f099246d3f0761 (diff) |
[OOM-K8S-CERT-EXTERNAL-PROVIDER] Add project
This project is a GOlang implementation of an external provider for kubernetes cert-manager.
External provider will use OOM CertService as backend signing CA.
Issue-ID: OOM-2559
Signed-off-by: Jan Malkiewicz <jan.malkiewicz@nokia.com>
Change-Id: Ide31ca64c29763c9d4e9bdf58d8f50ffddcaaf5d
Diffstat (limited to 'certServiceK8sExternalProvider')
-rw-r--r-- | certServiceK8sExternalProvider/.gitignore | 1 | ||||
-rw-r--r-- | certServiceK8sExternalProvider/Dockerfile | 22 | ||||
-rw-r--r-- | certServiceK8sExternalProvider/Makefile | 9 | ||||
-rw-r--r-- | certServiceK8sExternalProvider/README.md | 9 | ||||
-rw-r--r-- | certServiceK8sExternalProvider/go.mod | 9 | ||||
-rw-r--r-- | certServiceK8sExternalProvider/go.sum | 17 | ||||
-rw-r--r-- | certServiceK8sExternalProvider/main.go | 24 | ||||
-rw-r--r-- | certServiceK8sExternalProvider/pom.xml | 144 | ||||
-rw-r--r-- | certServiceK8sExternalProvider/src/certservice-provisioner/certservice-provisioner.go | 7 | ||||
-rw-r--r-- | certServiceK8sExternalProvider/test/certservice-provisioner/certservice-provisioner_test.go | 13 |
10 files changed, 255 insertions, 0 deletions
diff --git a/certServiceK8sExternalProvider/.gitignore b/certServiceK8sExternalProvider/.gitignore new file mode 100644 index 00000000..ba077a40 --- /dev/null +++ b/certServiceK8sExternalProvider/.gitignore @@ -0,0 +1 @@ +bin diff --git a/certServiceK8sExternalProvider/Dockerfile b/certServiceK8sExternalProvider/Dockerfile new file mode 100644 index 00000000..baea932b --- /dev/null +++ b/certServiceK8sExternalProvider/Dockerfile @@ -0,0 +1,22 @@ +# Build the manager binary +FROM golang:1.15.2 as builder + +WORKDIR /workspace +# Copy the Go Modules manifests +COPY go.* ./ +# cache deps before building and copying source so that we don't need to re-download as much +# and so that source changes don't invalidate our downloaded layer +RUN go mod download + +# Copy the go source +COPY main.go main.go + +# Build +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o oom-certservice-k8s-external-provider main.go + + +# Runtime container definition +FROM gcr.io/distroless/static:latest +WORKDIR / +COPY --from=builder /workspace/oom-certservice-k8s-external-provider . +ENTRYPOINT ["/oom-certservice-k8s-external-provider"] diff --git a/certServiceK8sExternalProvider/Makefile b/certServiceK8sExternalProvider/Makefile new file mode 100644 index 00000000..2fac43e0 --- /dev/null +++ b/certServiceK8sExternalProvider/Makefile @@ -0,0 +1,9 @@ +build: + go build -v -o bin//oom-certservice-k8s-external-provider oom-certservice/k8s-external-provider + +build-docker-image: + docker build -t onap/oom-certservice-k8s-external-provider . + +run-docker-image: + docker run -it onap/oom-certservice-k8s-external-provider + diff --git a/certServiceK8sExternalProvider/README.md b/certServiceK8sExternalProvider/README.md new file mode 100644 index 00000000..55eb0d0c --- /dev/null +++ b/certServiceK8sExternalProvider/README.md @@ -0,0 +1,9 @@ +## Project seed for applications written in go lang + +### Build project + +Just run **mvn** command without any parameters (which is by default equal to **mvn clean package**). + +The output executable file will be present in bin directory with name: **onap-golang-helloworld-1.0.0-SNAPSHOT** + +To run the program just type: **bin/onap-golang-helloworld-1.0.0-SNAPSHOT** diff --git a/certServiceK8sExternalProvider/go.mod b/certServiceK8sExternalProvider/go.mod new file mode 100644 index 00000000..2d611841 --- /dev/null +++ b/certServiceK8sExternalProvider/go.mod @@ -0,0 +1,9 @@ +module onap.org/oom-certservice/k8s-external-provider + +go 1.15 + +require ( + // Apache 2.0 license: https://github.com/levigross/grequests/blob/master/LICENSE + github.com/levigross/grequests v0.0.0-20190908174114-253788527a1a + golang.org/x/net v0.0.0-20200927032502-5d4f70055728 // indirect +) diff --git a/certServiceK8sExternalProvider/go.sum b/certServiceK8sExternalProvider/go.sum new file mode 100644 index 00000000..c2501685 --- /dev/null +++ b/certServiceK8sExternalProvider/go.sum @@ -0,0 +1,17 @@ +github.com/go-logr/logr v0.2.1 h1:fV3MLmabKIZ383XifUjFSwcoGee0v9qgPp8wy5svibE= +github.com/go-logr/logr v0.2.1/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= +github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/levigross/grequests v0.0.0-20190908174114-253788527a1a h1:DGFy/362j92vQRE3ThU1yqg9TuJS8YJOSbQuB7BP9cA= +github.com/levigross/grequests v0.0.0-20190908174114-253788527a1a/go.mod h1:jVntzcUU+2BtVohZBQmSHWUmh8B55LCNfPhcNCIvvIg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1 h1:Y/KGZSOdz/2r0WJ9Mkmz6NJBusp0kiNx1Cn82lzJQ6w= +golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200927032502-5d4f70055728 h1:5wtQIAulKU5AbLQOkjxl32UufnIOqgBX72pS0AV14H0= +golang.org/x/net v0.0.0-20200927032502-5d4f70055728/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/certServiceK8sExternalProvider/main.go b/certServiceK8sExternalProvider/main.go new file mode 100644 index 00000000..77ede105 --- /dev/null +++ b/certServiceK8sExternalProvider/main.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + "github.com/levigross/grequests" + "log" + certservice_provisioner "onap.org/oom-certservice/k8s-external-provider/src/certservice-provisioner" +) + +func main() { + fmt.Println(" *** Hello World Golang App ***") + fmt.Println() + + resp, err := grequests.Get("http://jenkins.onap.org/", nil) + + if err != nil { + log.Fatalln("Unable to make request: ", err) + } + + fmt.Println("Checking if jenkins.onap.org is reachable:", resp.StatusCode) + + fmt.Println("Signing certificate...") + certservice_provisioner.SignCertificate() +} diff --git a/certServiceK8sExternalProvider/pom.xml b/certServiceK8sExternalProvider/pom.xml new file mode 100644 index 00000000..6be62b77 --- /dev/null +++ b/certServiceK8sExternalProvider/pom.xml @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>oom-certservice</artifactId> + <groupId>org.onap.oom.platform.cert-service</groupId> + <version>2.1.1-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>oom-certservice-k8s-external-provider</artifactId> + <packaging>mvn-golang</packaging> + + <properties> + <version.mvn-clean-plugin>3.1.0</version.mvn-clean-plugin> + <version.mvn-golang-wrapper-plugin>2.3.5</version.mvn-golang-wrapper-plugin> + </properties> + + <build> + <!--Changing standard Maven project source structure to make it Go compatible--> + <sourceDirectory>${basedir}</sourceDirectory> + <directory>${basedir}${file.separator}bin</directory> + + <defaultGoal>clean package</defaultGoal> + + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + <version>${version.mvn-clean-plugin}</version> + <configuration> + <followSymLinks>false</followSymLinks> + <excludeDefaultDirectories>true</excludeDefaultDirectories> + <filesets> + <fileset> + <directory>${basedir}${file.separator}bin</directory> + </fileset> + </filesets> + </configuration> + </plugin> + <plugin> + <groupId>com.igormaznitsa</groupId> + <artifactId>mvn-golang-wrapper</artifactId> + <version>${version.mvn-golang-wrapper-plugin}</version> + <extensions>true</extensions> + <executions> + <execution> + <id>run</id> + <goals> + <goal>run</goal> + </goals> + <configuration> + <packages> + <package>onap.org/oom-certservice/k8s-external-provider</package> + </packages> + </configuration> + </execution> + <execution> + <id>install</id> + <goals> + <goal>install</goal> + </goals> + <configuration> + <packages> + <package>onap.org/oom-certservice/k8s-external-provider/main</package> + <package>onap.org/oom-certservice/k8s-external-provider/certservice-provisioner</package> + </packages> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <profiles> + + <profile> + <id>docker-staging</id> + <properties> + <docker.tag>${project.version}-STAGING-${maven.build.timestamp}</docker.tag> + <docker.latest.tag>${project.version}-STAGING-latest</docker.latest.tag> + </properties> + </profile> + + <profile> + <id>docker</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <properties> + <os.detected.name>linux</os.detected.name> + <os.detected.arch>x86_64</os.detected.arch> + <os.detected.classifier>${os.detected.name}-${os.detected.arch}</os.detected.classifier> + </properties> + <build> + <plugins> + <plugin> + <groupId>io.fabric8</groupId> + <artifactId>docker-maven-plugin</artifactId> + <version>${docker-maven-plugin.version}</version> + <executions> + <execution> + <id>docker-build-image</id> + <phase>package</phase> + <goals> + <goal>build</goal> + </goals> + </execution> + <execution> + <id>docker-push-image</id> + <phase>deploy</phase> + <goals> + <goal>push</goal> + </goals> + </execution> + </executions> + <configuration> + <skipPush>${skipDockerPush}</skipPush> + <verbose>true</verbose> + <imagePullPolicy>IfNotPresent</imagePullPolicy> + <images> + <image> + <alias>${project.artifactId}</alias> + <name>${docker-image.namespace}/${docker-image.name}:${docker-image.tag.latest} + </name> + <registry>${docker-image.registry}</registry> + <build> + <dockerFileDir>${project.basedir}</dockerFileDir> + <tags> + <tag>${project.version}-${maven.build.timestamp}Z</tag> + </tags> + </build> + </image> + </images> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> + + +</project> diff --git a/certServiceK8sExternalProvider/src/certservice-provisioner/certservice-provisioner.go b/certServiceK8sExternalProvider/src/certservice-provisioner/certservice-provisioner.go new file mode 100644 index 00000000..5648082a --- /dev/null +++ b/certServiceK8sExternalProvider/src/certservice-provisioner/certservice-provisioner.go @@ -0,0 +1,7 @@ +package certservice_provisioner + +import "fmt" + +func SignCertificate() { + fmt.Println("--> This method is currently a stub.") +} diff --git a/certServiceK8sExternalProvider/test/certservice-provisioner/certservice-provisioner_test.go b/certServiceK8sExternalProvider/test/certservice-provisioner/certservice-provisioner_test.go new file mode 100644 index 00000000..a9435e2d --- /dev/null +++ b/certServiceK8sExternalProvider/test/certservice-provisioner/certservice-provisioner_test.go @@ -0,0 +1,13 @@ +package certservice_provisioner + +import ( + certservice_provisioner "onap.org/oom-certservice/k8s-external-provider/src/certservice-provisioner" + "testing" +) + +func TestSignCertificate(t *testing.T) { + + certservice_provisioner.SignCertificate() + + t.Logf("Everything is OK.") +} |