Skip to content

Commit 0b502b7

Browse files
authored
Features (#207)
* NetworkConfig: filter the peers to be added per organization * Filter peers by org, global peers and global CAs * Add `FabricChaincodeTemplate` CRD * update * Add support for FabricChaincodeTemplateRef in FabricChaincodeSpec Signed-off-by: David VIEJO <[email protected]> * update * Update helm chart in pipelien Signed-off-by: David VIEJO <[email protected]> * Update Signed-off-by: David VIEJO <[email protected]> * update Signed-off-by: David VIEJO <[email protected]> * Update Signed-off-by: David VIEJO <[email protected]> * update * fabric-config 0.1.0 -> 0.2.1 Add ports 443 for the peer * Upgrade to go 1.21 * Add adminURL in the network config if available --------- Signed-off-by: David VIEJO <[email protected]>
1 parent ee0a9d9 commit 0b502b7

File tree

255 files changed

+4183
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

255 files changed

+4183
-253
lines changed

.github/workflows/test-kubectl-plugin.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- name: Deploy operator
4545
run: |
4646
helm repo add kfs https://kfsoftware.github.io/hlf-helm-charts --force-update
47-
helm install hlf-operator --version=1.9.0-beta4 kfs/hlf-operator --set image.repository="${IMAGE}" --set image.tag="${TAG}" --set image.pullPolicy="IfNotPresent"
47+
helm install hlf-operator --version=1.10.0-beta2 kfs/hlf-operator --set image.repository="${IMAGE}" --set image.tag="${TAG}" --set image.pullPolicy="IfNotPresent"
4848
4949
- name: Install operator CRDs
5050
run: |
@@ -143,9 +143,8 @@ jobs:
143143
health {
144144
lameduck 5s
145145
}
146-
rewrite name regex (.*)\.localho\.st host.ingress.internal
146+
rewrite name regex (.*)\.localho\.st istio-ingressgateway.istio-system.svc.cluster.local
147147
hosts {
148-
${CLUSTER_IP} host.ingress.internal
149148
fallthrough
150149
}
151150
ready

api/hlf.kungfusoftware.es/v1alpha1/hlf_types.go

+195-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type ExternalBuilder struct {
8888
PropagateEnvironment []string `json:"propagateEnvironment"`
8989
}
9090

91-
const DefaultImagePullPolicy = corev1.PullAlways
91+
const DefaultImagePullPolicy = corev1.PullIfNotPresent
9292

9393
type ServiceMonitor struct {
9494
// +kubebuilder:default:=false
@@ -1581,15 +1581,36 @@ type FabricOperatorAPISpec struct {
15811581
Resources *corev1.ResourceRequirements `json:"resources"`
15821582
}
15831583

1584+
type FabricNetworkConfigOrgPeer struct {
1585+
Name string `json:"name"`
1586+
Namespace string `json:"namespace"`
1587+
}
1588+
type FabricNetworkConfigOrganization struct {
1589+
Peers []FabricNetworkConfigOrgPeer `json:"peers"`
1590+
}
1591+
type FabricNetworkConfigCA struct {
1592+
Name string `json:"name"`
1593+
Namespace string `json:"namespace"`
1594+
}
1595+
15841596
// FabricNetworkConfigSpec defines the desired state of FabricNetworkConfig
15851597
type FabricNetworkConfigSpec struct {
15861598
Organization string `json:"organization"`
15871599

15881600
Internal bool `json:"internal"`
15891601

15901602
Organizations []string `json:"organizations"`
1591-
1592-
Namespaces []string `json:"namespaces"`
1603+
// +kubebuilder:validation:Default={}
1604+
// +optional
1605+
// +kubebuilder:validation:Optional
1606+
// +nullable
1607+
OrganizationConfig map[string]FabricNetworkConfigOrganization `json:"organizationConfig"`
1608+
Namespaces []string `json:"namespaces"`
1609+
// +nullable
1610+
// +kubebuilder:validation:Optional
1611+
// +optional
1612+
// +kubebuilder:validation:Default={}
1613+
CertificateAuthorities []FabricNetworkConfigCA `json:"certificateAuthorities"`
15931614

15941615
Channels []string `json:"channels"`
15951616
// HLF Identities to be included in the network config
@@ -1662,8 +1683,18 @@ type FabricNetworkConfigList struct {
16621683
Items []FabricNetworkConfig `json:"items"`
16631684
}
16641685

1686+
type FabricChaincodeTemplateRef struct {
1687+
Name string `json:"name"`
1688+
Namespace string `json:"namespace"`
1689+
}
1690+
16651691
// FabricChaincodeSpec defines the desired state of FabricChaincode
16661692
type FabricChaincodeSpec struct {
1693+
// +nullable
1694+
// +optional
1695+
// +kubebuilder:validation:Optional
1696+
Template *FabricChaincodeTemplateRef `json:"template"`
1697+
16671698
// +nullable
16681699
// +optional
16691700
// +kubebuilder:validation:Optional
@@ -1746,6 +1777,56 @@ type FabricChaincodeSpec struct {
17461777
MspID string `json:"mspID"`
17471778
}
17481779

1780+
func (in *FabricChaincodeSpec) ApplyDefaultValuesFromTemplate(template *FabricChaincodeTemplate) {
1781+
if in.ImagePullPolicy == "" {
1782+
in.ImagePullPolicy = template.Spec.ImagePullPolicy
1783+
}
1784+
if in.ImagePullSecrets == nil || len(in.ImagePullSecrets) == 0 {
1785+
in.ImagePullSecrets = template.Spec.ImagePullSecrets
1786+
}
1787+
if in.Command == nil || len(in.Command) == 0 {
1788+
in.Command = template.Spec.Command
1789+
}
1790+
if in.Args == nil || len(in.Args) == 0 {
1791+
in.Args = template.Spec.Args
1792+
}
1793+
if in.Affinity == nil {
1794+
in.Affinity = template.Spec.Affinity
1795+
}
1796+
if in.Tolerations == nil || len(in.Tolerations) == 0 {
1797+
in.Tolerations = template.Spec.Tolerations
1798+
}
1799+
if in.Resources == nil {
1800+
in.Resources = template.Spec.Resources
1801+
}
1802+
if in.Replicas == 0 {
1803+
in.Replicas = template.Spec.Replicas
1804+
}
1805+
if in.Env == nil || len(in.Env) == 0 {
1806+
in.Env = template.Spec.Env
1807+
} else {
1808+
for _, env := range template.Spec.Env {
1809+
found := false
1810+
for _, e := range in.Env {
1811+
if e.Name == env.Name {
1812+
found = true
1813+
break
1814+
}
1815+
}
1816+
if !found {
1817+
in.Env = append(in.Env, env)
1818+
}
1819+
1820+
}
1821+
}
1822+
if in.ChaincodeServerPort == 0 {
1823+
in.ChaincodeServerPort = template.Spec.ChaincodeServerPort
1824+
}
1825+
if in.MspID == "" {
1826+
in.MspID = template.Spec.MspID
1827+
}
1828+
}
1829+
17491830
// FabricChaincodeStatus defines the observed state of FabricChaincode
17501831
type FabricChaincodeStatus struct {
17511832
Conditions status.Conditions `json:"conditions"`
@@ -2229,8 +2310,119 @@ type FabricFollowerChannelOrderer struct {
22292310
Certificate string `json:"certificate"`
22302311
}
22312312

2313+
// FabricChaincodeTemplateStatus defines the observed state of FabricChaincodeTemplate
2314+
type FabricChaincodeTemplateStatus struct {
2315+
Conditions status.Conditions `json:"conditions"`
2316+
Message string `json:"message"`
2317+
// Status of the FabricCA
2318+
Status DeploymentStatus `json:"status"`
2319+
}
2320+
2321+
// +genclient
2322+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
2323+
// +k8s:defaulter-gen=true
2324+
// +kubebuilder:subresource:status
2325+
// +kubebuilder:resource:scope=Namespaced,shortName=fabricchaincodetemplate,singular=fabricchaincodetemplate
2326+
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.status"
2327+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
2328+
2329+
// FabricChaincodeTemplate is the Schema for the hlfs API
2330+
type FabricChaincodeTemplate struct {
2331+
metav1.TypeMeta `json:",inline"`
2332+
metav1.ObjectMeta `json:"metadata,omitempty"`
2333+
Spec FabricChaincodeTemplateSpec `json:"spec,omitempty"`
2334+
Status FabricChaincodeTemplateStatus `json:"status,omitempty"`
2335+
}
2336+
2337+
// +kubebuilder:object:root=true
2338+
2339+
// FabricChaincodeTemplateList contains a list of FabricChaincodeTemplate
2340+
type FabricChaincodeTemplateList struct {
2341+
metav1.TypeMeta `json:",inline"`
2342+
metav1.ListMeta `json:"metadata,omitempty"`
2343+
Items []FabricChaincodeTemplate `json:"items"`
2344+
}
2345+
2346+
// FabricChaincodeTemplateSpec defines the desired state of FabricChaincodeTemplate
2347+
type FabricChaincodeTemplateSpec struct {
2348+
// +nullable
2349+
// +optional
2350+
// +kubebuilder:validation:Optional
2351+
// +kubebuilder:default:={}
2352+
Annotations map[string]string `json:"annotations"`
2353+
// +nullable
2354+
// +optional
2355+
// +kubebuilder:validation:Optional
2356+
// +kubebuilder:default:={}
2357+
Labels map[string]string `json:"labels"`
2358+
2359+
// +nullable
2360+
// +optional
2361+
// +kubebuilder:validation:Optional
2362+
// +kubebuilder:default:={}
2363+
PodAnnotations map[string]string `json:"podAnnotations"`
2364+
2365+
// +nullable
2366+
// +optional
2367+
// +kubebuilder:validation:Optional
2368+
// +kubebuilder:default:={}
2369+
PodLabels map[string]string `json:"podLabels"`
2370+
2371+
// +kubebuilder:default:="IfNotPresent"
2372+
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy"`
2373+
2374+
// +kubebuilder:validation:Default={}
2375+
// +optional
2376+
// +kubebuilder:validation:Optional
2377+
// +nullable
2378+
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets"`
2379+
2380+
// Entrypoint array. Not executed within a shell.
2381+
// The container image's ENTRYPOINT is used if this is not provided.
2382+
// +optional
2383+
Command []string `json:"command,omitempty" protobuf:"bytes,3,rep,name=command"`
2384+
2385+
// Arguments to the entrypoint.
2386+
// The container image's CMD is used if this is not provided.
2387+
// +optional
2388+
Args []string `json:"args,omitempty" protobuf:"bytes,4,rep,name=args"`
2389+
2390+
// +nullable
2391+
// +kubebuilder:validation:Optional
2392+
// +optional
2393+
Affinity *corev1.Affinity `json:"affinity"`
2394+
2395+
// +nullable
2396+
// +kubebuilder:validation:Optional
2397+
// +optional
2398+
// +kubebuilder:validation:Default={}
2399+
Tolerations []corev1.Toleration `json:"tolerations"`
2400+
2401+
// +nullable
2402+
// +kubebuilder:validation:Optional
2403+
// +optional
2404+
Resources *corev1.ResourceRequirements `json:"resources"`
2405+
2406+
// +kubebuilder:validation:Default=1
2407+
Replicas int `json:"replicas"`
2408+
2409+
// +nullable
2410+
// +kubebuilder:validation:Optional
2411+
// +optional
2412+
// +kubebuilder:validation:Default={}
2413+
Env []corev1.EnvVar `json:"env"`
2414+
2415+
// +kubebuilder:default=7052
2416+
ChaincodeServerPort int `json:"chaincodeServerPort"`
2417+
2418+
// +optional
2419+
// +kubebuilder:validation:Optional
2420+
MspID string `json:"mspID"`
2421+
}
2422+
22322423
func init() {
22332424
SchemeBuilder.Register(&FabricPeer{}, &FabricPeerList{})
2425+
SchemeBuilder.Register(&FabricChaincodeTemplate{}, &FabricChaincodeTemplateList{})
22342426
SchemeBuilder.Register(&FabricOrderingService{}, &FabricOrderingServiceList{})
22352427
SchemeBuilder.Register(&FabricCA{}, &FabricCAList{})
22362428
SchemeBuilder.Register(&FabricOrdererNode{}, &FabricOrdererNodeList{})

0 commit comments

Comments
 (0)