Skip to content

Commit

Permalink
Support for external builders
Browse files Browse the repository at this point in the history
  • Loading branch information
dviejokfs committed Mar 27, 2021
1 parent e78ed14 commit fa50065
Show file tree
Hide file tree
Showing 21 changed files with 183 additions and 72 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
bin
website-docs
website-docs
dist
kubectl-hlf
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ keystore
kubectl-hlf/kubectl-hlf
*.minisig
*.zip
dist/
dist/
hlf-operator
21 changes: 19 additions & 2 deletions api/hlf.kungfusoftware.es/v1alpha1/hlf_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1alpha1
import (
"fmt"
"github.com/operator-framework/operator-lib/status"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -53,12 +54,20 @@ const (
LevelDBState = "leveldb"
)

type ExternalBuilder struct {
Name string `json:"name"`
Path string `json:"path"`
}

const DefaultImagePullPolicy = corev1.PullAlways

// FabricPeerSpec defines the desired state of FabricPeer
type FabricPeerSpec struct {
// +kubebuilder:default:="/var/run/docker.sock"
DockerSocketPath string `json:"dockerSocketPath"`
// +kubebuilder:validation:MinLength=1
Image string `json:"image"`
Image string `json:"image"`
ExternalBuilders []ExternalBuilder `json:"externalBuilders"`
// +optional
// +kubebuilder:validation:Optional
// +nullable
Expand All @@ -67,6 +76,7 @@ type FabricPeerSpec struct {
ExternalEndpoint string `json:"externalEndpoint"`
// +kubebuilder:validation:MinLength=1
Tag string `json:"tag"`
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
ExternalChaincodeBuilder bool `json:"external_chaincode_builder"`
CouchDB FabricPeerCouchDB `json:"couchdb"`
// +kubebuilder:validation:MinLength=3
Expand Down Expand Up @@ -112,6 +122,7 @@ type FabricPeerCouchDB struct {
}

type FabricPeerIstio struct {
// +optional
// +nullable
Port int `json:"port"`
// +nullable
Expand Down Expand Up @@ -328,8 +339,9 @@ type FabricCADatabase struct {

// FabricCASpec defines the desired state of FabricCA
type FabricCASpec struct {
// +kubebuilder:validation:Optional
// +optional
// +kubebuilder:validation:Optional
// +nullable
Istio *FabricCAIstio `json:"istio"`
Database FabricCADatabase `json:"db"`
// +kubebuilder:validation:MinItems=1
Expand All @@ -354,8 +366,13 @@ type FabricCASpec struct {
}
type FabricCAIstio struct {
// +kubebuilder:validation:Optional
// +optional
// +nullable
Port int `json:"port"`
// +nullable
// +kubebuilder:validation:Optional
// +optional
// +kubebuilder:validation:Default={}
Hosts []string `json:"hosts"`
}
type FabricCATLSConf struct {
Expand Down
20 changes: 20 additions & 0 deletions api/hlf.kungfusoftware.es/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion chart/hlf-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ image:
repository: quay.io/kfsoftware/hlf-operator
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: "v1.0.0"
tag: "v1.1.0"

imagePullSecrets: []
nameOverride: ""
Expand Down
4 changes: 4 additions & 0 deletions charts/hlf-peer/templates/configmap--peer--core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ data:
# chaincode. The external builder detection processing will iterate over the
# builders in the order specified below.
externalBuilders:
{{- if $.Values.externalBuilders }}
{{ $.Values.externalBuilders | toYaml | indent 8 }}
{{- else }}
{{- if $.Values.externalChaincodeBuilder }}
- name: my-golang-builder
path: /builders/golang
Expand All @@ -569,6 +572,7 @@ data:
- EXTERNAL_BUILDER_HTTPS_PROXY
- EXTERNAL_BUILDER_NO_PROXY
- EXTERNAL_BUILDER_PEER_URL
{{- end }}
{{- end }}
# The maximum duration to wait for the chaincode build and install process
# to complete.
Expand Down
7 changes: 3 additions & 4 deletions charts/hlf-peer/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ spec:
release: {{ .Release.Name }}
# Ensure we allow our pod to be unavailable, so we can upgrade
strategy:
rollingUpdate:
maxUnavailable: 1
type: Recreate
template:
metadata:
labels:
Expand Down Expand Up @@ -142,8 +141,8 @@ spec:
env:
- name: FILE_SERVER_BASE_IP
value: {{ include "hlf-peer.fullname" . }}-fs
{{/* - name: EXTERNAL_BUILDER_PEER_URL*/}}
{{/* value: {{ include "hlf-peer.fullname" . }}:7052*/}}
- name: EXTERNAL_BUILDER_PEER_URL
value: {{ include "hlf-peer.fullname" . }}:7052
- name: K8SCC_CFGFILE
value: "/builders/golang/bin/k8scc.yaml"
- name: FILE_SERVER_ENDPOINT
Expand Down
40 changes: 24 additions & 16 deletions charts/hlf-peer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ dockerSocketPath: /var/run/docker.sock

ingress:
enabled: false
annotations: {}
annotations: { }
path: /
hosts:
- hlf-peer.local
tls: []
tls: [ ]
# - secretName: hlf-peer-tls
# hosts:
# - hlf-peer.local
Expand Down Expand Up @@ -144,23 +144,23 @@ tlsrootcert: |
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi

nodeSelector: {}
nodeSelector: { }

tolerations: []
tolerations: [ ]

affinity: {}
affinity: { }


externalHost: peer0:443
fullnameOverride: peer0
hostAliases: []
hostAliases: [ ]
service:
type: NodePort
portRequest: 7051
Expand All @@ -170,19 +170,19 @@ service:
persistence:
peer:
enabled: true
annotations: {}
annotations: { }
storageClass:
accessMode: ReadWriteOnce
size: 1Gi
couchdb:
enabled: true
annotations: {}
annotations: { }
storageClass:
accessMode: ReadWriteOnce
size: 1Gi
chaincode:
enabled: true
annotations: {}
annotations: { }
storageClass:
accessMode: ReadWriteOnce
size: 1Gi
Expand All @@ -196,4 +196,12 @@ logging:
msp: debug
policies: warning

externalChaincodeBuilder: false
externalChaincodeBuilder: false

externalBuilders:
- path: "12"
name: external-sample-builder

opsTLS:
key: ""
cert: ""
3 changes: 3 additions & 0 deletions config/crd/bases/hlf.kungfusoftware.es_fabriccas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,15 @@ spec:
minLength: 1
type: string
istio:
nullable: true
properties:
hosts:
items:
type: string
nullable: true
type: array
port:
nullable: true
type: integer
type: object
metrics:
Expand Down
19 changes: 17 additions & 2 deletions config/crd/bases/hlf.kungfusoftware.es_fabricpeers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ spec:
type: string
external_chaincode_builder:
type: boolean
externalBuilders:
items:
properties:
name:
type: string
path:
type: string
required:
- name
- path
type: object
type: array
externalEndpoint:
type: string
gossip:
Expand Down Expand Up @@ -98,6 +110,10 @@ spec:
image:
minLength: 1
type: string
imagePullPolicy:
description: PullPolicy describes a policy for if/when to pull a container
image
type: string
istio:
nullable: true
properties:
Expand All @@ -109,8 +125,6 @@ spec:
port:
nullable: true
type: integer
required:
- port
type: object
logging:
properties:
Expand Down Expand Up @@ -418,6 +432,7 @@ spec:
- couchdb
- discovery
- dockerSocketPath
- externalBuilders
- externalEndpoint
- external_chaincode_builder
- gossip
Expand Down
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ kind: Kustomization
images:
- name: controller
newName: quay.io/kfsoftware/hlf-operator
newTag: v1.1.0
newTag: v1.2.0-beta
4 changes: 2 additions & 2 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ spec:
name: manager
resources:
limits:
cpu: 100m
memory: 30Mi
cpu: 2000m
memory: 200Mi
requests:
cpu: 100m
memory: 20Mi
Expand Down
2 changes: 1 addition & 1 deletion controllers/ca/ca_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ func GetCAState(clientSet *kubernetes.Clientset, ca *hlfv1alpha1.FabricCA, relea
r.Status = hlfv1alpha1.PendingStatus
}
}
if len(ca.Spec.Istio.Hosts) > 0 {
if ca.Spec.Istio != nil && len(ca.Spec.Istio.Hosts) > 0 {
r.URL = fmt.Sprintf("https://%s:%d", ca.Spec.Istio.Hosts[0], ca.Spec.Istio.Port)
r.Host = ca.Spec.Istio.Hosts[0]
r.Port = ca.Spec.Istio.Port
Expand Down
14 changes: 13 additions & 1 deletion controllers/peer/peer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,12 +685,24 @@ func GetConfig(conf *hlfv1alpha1.FabricPeer, client *kubernetes.Clientset, chart
if gossipEndpoint == "" {
gossipEndpoint = externalEndpoint
}
externalBuilders := []ExternalBuilder{}
for _, builder := range spec.ExternalBuilders {
externalBuilders = append(externalBuilders, ExternalBuilder{
Name: builder.Name,
Path: builder.Path,
})
}
imagePullPolicy := spec.ImagePullPolicy
if imagePullPolicy == "" {
imagePullPolicy = hlfv1alpha1.DefaultImagePullPolicy
}
var c = FabricPeerChart{
Image: Image{
Repository: spec.Image,
Tag: spec.Tag,
PullPolicy: "Always",
PullPolicy: string(imagePullPolicy),
},
ExternalBuilders: externalBuilders,
DockerSocketPath: spec.DockerSocketPath,
Peer: Peer{
DatabaseType: string(spec.StateDb),
Expand Down
Loading

0 comments on commit fa50065

Please sign in to comment.