Skip to content

Commit

Permalink
Merge pull request #20 from canonical/IAM-365
Browse files Browse the repository at this point in the history
IAM 365
  • Loading branch information
shipperizer authored Aug 10, 2023
2 parents 0dc33c4 + bb3bd28 commit b16b00e
Show file tree
Hide file tree
Showing 21 changed files with 2,865 additions and 32 deletions.
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM --platform=$BUILDPLATFORM golang:1.20 AS builder

LABEL org.opencontainers.image.source=https://github.com/canonical/identity-platform-admin-ui

ARG SKAFFOLD_GO_GCFLAGS
ARG TARGETOS
ARG TARGETARCH
ARG app_name=reader

ENV GOOS=$TARGETOS
ENV GOARCH=$TARGETARCH
ENV GO111MODULE=on
ENV CGO_ENABLED=0
ENV GO_BIN=/go/bin/app
ENV APP_NAME=$app_name

WORKDIR /var/app

COPY . .

RUN make build

FROM gcr.io/distroless/static:nonroot

LABEL org.opencontainers.image.source=https://github.com/canonical/identity-platform-admin-ui

COPY --from=builder /go/bin/app /app

CMD ["/app"]
16 changes: 15 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import (
"time"

ih "github.com/canonical/identity-platform-admin-ui/internal/hydra"
"github.com/canonical/identity-platform-admin-ui/internal/k8s"
"github.com/kelseyhightower/envconfig"

"github.com/canonical/identity-platform-admin-ui/internal/config"
ik "github.com/canonical/identity-platform-admin-ui/internal/kratos"
"github.com/canonical/identity-platform-admin-ui/internal/logging"
"github.com/canonical/identity-platform-admin-ui/internal/monitoring/prometheus"
"github.com/canonical/identity-platform-admin-ui/internal/tracing"
"github.com/canonical/identity-platform-admin-ui/pkg/idp"
"github.com/canonical/identity-platform-admin-ui/pkg/web"
)

Expand All @@ -37,7 +39,19 @@ func main() {
hClient := ih.NewClient(specs.HydraAdminURL, specs.Debug)
kClient := ik.NewClient(specs.KratosURL, specs.Debug)

router := web.NewRouter(hClient, kClient, tracer, monitor, logger)
k8sCoreV1, err := k8s.NewCoreV1Client()

if err != nil {
panic(err)
}

idpConfig := &idp.Config{
K8s: k8sCoreV1,
Name: specs.ConfigMapName,
Namespace: specs.ConfigMapNamespace,
}

router := web.NewRouter(idpConfig, hClient, kClient, tracer, monitor, logger)

logger.Infof("Starting server on port %v", specs.Port)

Expand Down
51 changes: 51 additions & 0 deletions deployments/kubectl/configMap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: identity-platform-admin-ui
data:
PORT: "8000"
LOG_LEVEL: DEBUG
TRACING_ENABLED: "false"
KRATOS_URL: http://kratos.svc.cluster.local:4434
HYDRA_ADMIN_URL: http://hydra.svc.cluster.local:4445
CONFIGMAP_NAME: idps
CONFIGMAP_NAMESPACE: default
---
apiVersion: v1
kind: ConfigMap
metadata:
name: idps
data:
"idps.yaml": |
- id: microsoft_af675f353bd7451588e2b8032e315f6f
client_id: af675f35-3bd7-4515-88e2-b8032e315f6f
provider: microsoft
client_secret: 3y38Q~aslkdhaskjhd~W0xWDB.123u98asd
microsoft_tenant: e1574293-28de-4e94-87d5-b61c76fc14e1
mapper_url: file:///etc/config/kratos/microsoft_schema.jsonnet
scope:
- profile
- email
- address
- phone
- id: google_18fa2999e6c9475aa49515d933d8e8ce
client_id: 18fa2999-e6c9-475a-a495-15d933d8e8ce
provider: google
client_secret: 3y38Q~aslkdhaskjhd~W0xWDB.123u98asd
mapper_url: file:///etc/config/kratos/google_schema.jsonnet
scope:
- profile
- email
- address
- phone
- id: aws_18fa2999e6c9475aa49589d941d8e1zy
client_id: 18fa2999-e6c9-475a-a495-89d941d8e1zy
provider: aws
client_secret: 3y38Q~aslkdhaskjhd~W0xWDB.123u98asd
mapper_url: file:///etc/config/kratos/google_schema.jsonnet
scope:
- profile
- email
- address
- phone
48 changes: 48 additions & 0 deletions deployments/kubectl/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: identity-platform-admin-ui
spec:
replicas: 1
selector:
matchLabels:
app: identity-platform-admin-ui
strategy:
type: Recreate
template:
metadata:
labels:
app: identity-platform-admin-ui
annotations:
prometheus.io/path: /api/v0/metrics
prometheus.io/scrape: "true"
prometheus.io/port: "8000"
spec:
containers:
- image: ghcr.io/canonical/identity-platform-admin-ui
name: identity-platform-admin-ui
envFrom:
- configMapRef:
name: identity-platform-admin-ui
ports:
- name: http
containerPort: 8000
readinessProbe:
httpGet:
path: "/api/v0/status"
port: 8000
initialDelaySeconds: 1
failureThreshold: 10
timeoutSeconds: 5
periodSeconds: 30
livenessProbe:
httpGet:
path: "/api/v0/status"
port: 8000
initialDelaySeconds: 1
failureThreshold: 10
timeoutSeconds: 5
periodSeconds: 30
imagePullSecrets:
- name: regcred-github
19 changes: 19 additions & 0 deletions deployments/kubectl/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
apiVersion: v1
kind: Service
metadata:
annotations:
prometheus.io/path: /api/v0/metrics
prometheus.io/scrape: "true"
io.cilium/global-service: "true"
name: identity-platform-admin-ui
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: http
selector:
app: identity-platform-admin-ui
type: ClusterIP
---
43 changes: 35 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ module github.com/canonical/identity-platform-admin-ui
go 1.19

require (
github.com/go-chi/chi/v5 v5.0.8
github.com/go-chi/chi/v5 v5.0.10
github.com/go-chi/cors v1.2.1
github.com/golang/mock v1.6.0
github.com/google/uuid v1.3.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/ory/hydra-client-go/v2 v2.1.1
github.com/ory/kratos-client-go v0.13.1
Expand All @@ -22,37 +23,63 @@ require (
go.opentelemetry.io/otel/trace v1.16.0
go.uber.org/zap v1.24.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v3 v3.0.1
k8s.io/apimachinery v0.27.4
k8s.io/client-go v0.27.4
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/pprof v0.0.0-20221010195024-131d412537ea // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.12.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.1.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd // indirect
google.golang.org/grpc v1.55.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/api v0.27.4 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit b16b00e

Please sign in to comment.