Skip to content

Commit

Permalink
add webhook server implementation for tenants (#251)
Browse files Browse the repository at this point in the history
Current implementation provides a mechanism
where the tenant loads an ENV such as its
command line args remotely, this is to
facilitate faster zone addition times.
  • Loading branch information
harshavardhana authored Aug 12, 2020
1 parent e10e1a5 commit 2f86f4c
Show file tree
Hide file tree
Showing 15 changed files with 311 additions and 65 deletions.
2 changes: 1 addition & 1 deletion examples/tenant-console.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
prometheus.io/port: "9000"
prometheus.io/scrape: "true"
## Registry location and Tag to download MinIO Server image
image: minio/minio:RELEASE.2020-08-05T21-34-13Z
image: minio/minio:RELEASE.2020-08-08T04-50-06Z
## Secret with credentials to be used by MinIO instance.
credsSecret:
name: minio-creds-secret
Expand Down
2 changes: 1 addition & 1 deletion examples/tenant-kes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
prometheus.io/port: "9000"
prometheus.io/scrape: "true"
## Registry location and Tag to download MinIO Server image
image: minio/minio:RELEASE.2020-08-05T21-34-13Z
image: minio/minio:RELEASE.2020-08-08T04-50-06Z
## Secret with credentials to be used by MinIO instance.
credsSecret:
name: minio-creds-secret
Expand Down
2 changes: 1 addition & 1 deletion examples/tenant-pod-security-policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ spec:
prometheus.io/port: "9000"
prometheus.io/scrape: "true"
## Registry location and Tag to download MinIO Server image
image: minio/minio:RELEASE.2020-08-05T21-34-13Z
image: minio/minio:RELEASE.2020-08-08T04-50-06Z
## Service account to be used for all the MinIO Pods
serviceAccountName: minio-pods
zones:
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ go 1.13

require (
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/google/go-cmp v0.4.1 // indirect
github.com/gorilla/mux v1.7.5-0.20200711200521-98cb6bf42e08
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imdario/mergo v0.3.10 // indirect
github.com/minio/minio v0.0.0-20200723003940-b9be841fd222
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEo
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/mux v1.7.5-0.20200711200521-98cb6bf42e08 h1:kPna6oIGlRXWmg/jkKfxbpvsl+0DHYnw1qQwN+6+gyA=
github.com/gorilla/mux v1.7.5-0.20200711200521-98cb6bf42e08/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/rpc v1.2.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
Expand Down
3 changes: 2 additions & 1 deletion kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kind: Kustomization
images:
- name: minio/k8s-operator
newName: minio/k8s-operator
newTag: v3.0.10
newTag: v3.0.11

namespace: minio-operator

Expand All @@ -15,4 +15,5 @@ resources:
- operator-kustomize/cluster-role.yaml
- operator-kustomize/cluster-role-binding.yaml
- operator-kustomize/crds/minio.min.io_tenants.yaml
- operator-kustomize/service.yaml
- operator-kustomize/deployment.yaml
16 changes: 16 additions & 0 deletions operator-kustomize/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: operator
labels:
name: minio-operator
namespace: minio-operator
spec:
type: ClusterIP
ports:
- port: 4222
name: http
- port: 4233
name: https
selector:
name: minio-operator
2 changes: 1 addition & 1 deletion pkg/apis/minio.min.io/v1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const MinIOVolumeMountPath = "/export"
const MinIOVolumeSubPath = ""

// DefaultMinIOImage specifies the default MinIO Docker hub image
const DefaultMinIOImage = "minio/minio:RELEASE.2020-08-05T21-34-13Z"
const DefaultMinIOImage = "minio/minio:RELEASE.2020-08-08T04-50-06Z"

// DefaultMinIOUpdateURL specifies the default MinIO URL where binaries are
// pulled from during MinIO upgrades
Expand Down
15 changes: 15 additions & 0 deletions pkg/apis/minio.min.io/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ import (
"github.com/minio/minio/pkg/madmin"
)

// Webhook API constants
const (
WebhookAPIVersion = "/webhook/v1"
WebhookDefaultPort = "4222"
WebhookOperatorSecret = "operator-webhook-secret"
WebhookOperatorUsername = "webhookUsername"
WebhookOperatorPassword = "webhookPassword"
)

// List of webhook APIs
const (
WebhookAPIGetenv = WebhookAPIVersion + "/getenv"
WebhookAPIBucketService = WebhookAPIVersion + "/bucketsrv"
)

type hostsTemplateValues struct {
StatefulSet string
CIService string
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/cluster/console-csr.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (c *Controller) createConsoleTLSCSR(ctx context.Context, mi *miniov1.Tenant
encodedPrivKey := pem.EncodeToMemory(&pem.Block{Type: privateKeyType, Bytes: privKeysBytes})

// Create secret for Console Deployment to use
err = c.createSecret(ctx, mi, mi.ConsolePodLabels(), mi.ConsoleTLSSecretName(), mi.Namespace, encodedPrivKey, certbytes)
err = c.createSecret(ctx, mi, mi.ConsolePodLabels(), mi.ConsoleTLSSecretName(), encodedPrivKey, certbytes)
if err != nil {
klog.Errorf("Unexpected error during the creation of the secret/%s: %v", mi.ConsoleTLSSecretName(), err)
return err
Expand Down
14 changes: 6 additions & 8 deletions pkg/controller/cluster/csr.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (c *Controller) createCSR(ctx context.Context, mi *miniov1.Tenant) error {
encodedPrivKey := pem.EncodeToMemory(&pem.Block{Type: privateKeyType, Bytes: privKeysBytes})

// Create secret for MinIO Statefulset to use
err = c.createSecret(ctx, mi, mi.MinIOPodLabels(), mi.MinIOTLSSecretName(), mi.Namespace, encodedPrivKey, certbytes)
err = c.createSecret(ctx, mi, mi.MinIOPodLabels(), mi.MinIOTLSSecretName(), encodedPrivKey, certbytes)
if err != nil {
klog.Errorf("Unexpected error during the creation of the secret/%s: %v", mi.MinIOTLSSecretName(), err)
return err
Expand Down Expand Up @@ -251,12 +251,12 @@ func (c *Controller) fetchCertificate(ctx context.Context, csrName string) ([]by
}
}

func (c *Controller) createSecret(ctx context.Context, mi *miniov1.Tenant, labels map[string]string, name, namespace string, pkBytes, certBytes []byte) error {
func (c *Controller) createSecret(ctx context.Context, mi *miniov1.Tenant, labels map[string]string, secretName string, pkBytes, certBytes []byte) error {
secret := &corev1.Secret{
Type: "Opaque",
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Name: secretName,
Namespace: mi.Namespace,
Labels: labels,
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(mi, schema.GroupVersionKind{
Expand All @@ -271,10 +271,8 @@ func (c *Controller) createSecret(ctx context.Context, mi *miniov1.Tenant, label
"public.crt": certBytes,
},
}
if _, err := c.kubeClientSet.CoreV1().Secrets(mi.Namespace).Create(ctx, secret, metav1.CreateOptions{}); err != nil {
return err
}
return nil
_, err := c.kubeClientSet.CoreV1().Secrets(mi.Namespace).Create(ctx, secret, metav1.CreateOptions{})
return err
}

func parseCertificate(r io.Reader) (*x509.Certificate, error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/cluster/kes-csr.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (c *Controller) createKESTLSCSR(ctx context.Context, mi *miniov1.Tenant) er
encodedPrivKey := pem.EncodeToMemory(&pem.Block{Type: privateKeyType, Bytes: privKeysBytes})

// Create secret for KES Statefulset to use
err = c.createSecret(ctx, mi, mi.KESPodLabels(), mi.KESTLSSecretName(), mi.Namespace, encodedPrivKey, certbytes)
err = c.createSecret(ctx, mi, mi.KESPodLabels(), mi.KESTLSSecretName(), encodedPrivKey, certbytes)
if err != nil {
klog.Errorf("Unexpected error during the creation of the secret/%s: %v", mi.KESTLSSecretName(), err)
return err
Expand Down Expand Up @@ -142,7 +142,7 @@ func (c *Controller) createMinIOClientTLSCSR(ctx context.Context, mi *miniov1.Te
encodedPrivKey := pem.EncodeToMemory(&pem.Block{Type: privateKeyType, Bytes: privKeysBytes})

// Create secret for KES Statefulset to use
err = c.createSecret(ctx, mi, mi.MinIOPodLabels(), mi.MinIOClientTLSSecretName(), mi.Namespace, encodedPrivKey, certbytes)
err = c.createSecret(ctx, mi, mi.MinIOPodLabels(), mi.MinIOClientTLSSecretName(), encodedPrivKey, certbytes)
if err != nil {
klog.Errorf("Unexpected error during the creation of the secret/%s: %v", mi.MinIOClientTLSSecretName(), err)
return err
Expand Down
Loading

0 comments on commit 2f86f4c

Please sign in to comment.