Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,27 @@ jobs:

- name: Test
run: make test

- name: Show information
if: ${{ failure() }}
run: |
kubectl get nodes -o=wide
kubectl get pods -o=wide -A
kubectl get service -o=wide -A
kubectl get crds
kubectl get fabricpeers.hlf.kungfusoftware.es -A -o=custom-columns='NAME:metadata.name,NAMESPACE:metadata.namespace,STATE:status.status,MESSAGE:status.message'
kubectl get fabricorderernodes.hlf.kungfusoftware.es -A -o=custom-columns='NAME:metadata.name,NAMESPACE:metadata.namespace,STATE:status.status,MESSAGE:status.message'
kubectl get fabriccas.hlf.kungfusoftware.es -A -o=custom-columns='NAME:metadata.name,NAMESPACE:metadata.namespace,STATE:status.status,MESSAGE:status.message'
kubectl get fabricmainchannels.hlf.kungfusoftware.es -A -o=custom-columns='NAME:metadata.name,NAMESPACE:metadata.namespace,STATE:status.status,MESSAGE:status.message'
kubectl get fabricfollowerchannels.hlf.kungfusoftware.es -A -o=custom-columns='NAME:metadata.name,NAMESPACE:metadata.namespace,STATE:status.status,MESSAGE:status.message'
kubectl get configmap coredns -n kube-system -o yaml
echo "Logs for hlf-operator deployment:"
kubectl logs -l app.kubernetes.io/name=hlf-operator -c manager --tail 2500
kubectl get fabricmainchannels -o yaml
kubectl get fabricfollowerchannels -o yaml

POD=$(kubectl get pod -l 'release in (org1-peer0)' -o jsonpath="{.items[0].metadata.name}")
kubectl logs $POD -c peer

POD=$(kubectl get pod -l 'release in (ord-node1)' -o jsonpath="{.items[0].metadata.name}")
kubectl logs $POD
2 changes: 1 addition & 1 deletion charts/hlf-ca/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
labels:
{{ include "labels.standard" . | indent 4 }}
spec:
replicas: 1
replicas: {{ .Values.replicas }}
selector:
matchLabels:
app: {{ include "hlf-ca.name" . }}
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/hlf.kungfusoftware.es_fabriccas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,9 @@ spec:
default: {}
nullable: true
type: object
replicas:
default: 1
type: integer
resources:
properties:
claims:
Expand Down Expand Up @@ -1555,6 +1558,7 @@ spec:
- hosts
- image
- metrics
- replicas
- resources
- rootCA
- service
Expand Down
14 changes: 12 additions & 2 deletions controllers/ca/ca_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import (
"encoding/json"
"encoding/pem"
"fmt"
"sort"

"github.com/go-logr/logr"
"github.com/kfsoftware/hlf-operator/controllers/hlfmetrics"
"github.com/kfsoftware/hlf-operator/pkg/status"
"helm.sh/helm/v3/pkg/cli"
"helm.sh/helm/v3/pkg/release"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sort"

"math/big"
"net"
Expand Down Expand Up @@ -642,7 +643,12 @@ func GetConfig(conf *hlfv1alpha1.FabricCA, client *kubernetes.Clientset, chartNa
Hosts: spec.Traefik.Hosts,
}
}
replicas := 1
if spec.Replicas != nil {
replicas = *spec.Replicas
}
var c = FabricCAChart{
Replicas: replicas,
PodLabels: spec.PodLabels,
PodAnnotations: spec.PodAnnotations,
ImagePullSecrets: spec.ImagePullSecrets,
Expand Down Expand Up @@ -761,7 +767,11 @@ func GetCAState(clientSet *kubernetes.Clientset, ca *hlfv1alpha1.FabricCA, relea
}
}
} else {
if dep.Status.ReadyReplicas == *dep.Spec.Replicas {
replicas := 1
if ca.Spec.Replicas != nil {
replicas = *ca.Spec.Replicas
}
if dep.Status.ReadyReplicas == int32(replicas) {
r.Status = hlfv1alpha1.RunningStatus
} else {
r.Status = hlfv1alpha1.PendingStatus
Expand Down
2 changes: 2 additions & 0 deletions controllers/ca/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type FabricCAChart struct {
ServiceMonitor ServiceMonitor `json:"serviceMonitor"`
EnvVars []corev1.EnvVar `json:"envVars"`
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets"`
// +kubebuilder:default:=1
Replicas int `json:"replicas"`
}
type ServiceMonitor struct {
Enabled bool `json:"enabled"`
Expand Down
13 changes: 8 additions & 5 deletions controllers/tests/ca_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"context"
"encoding/base64"
"fmt"
"strconv"
"strings"
"text/template"

"github.com/kfsoftware/hlf-operator/controllers/ca"
operatorv1alpha1 "github.com/kfsoftware/hlf-operator/pkg/client/clientset/versioned"
log "github.com/sirupsen/logrus"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"strconv"
"strings"
"text/template"

"github.com/Masterminds/sprig"
"github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt"
Expand Down Expand Up @@ -219,6 +220,7 @@ func randomFabricCA(releaseName string, namespace string) *hlfv1alpha1.FabricCA
Expect(err).ToNot(HaveOccurred())
k8sIP, err := utils.GetPublicIPKubernetes(ClientSet)
Expect(err).ToNot(HaveOccurred())
replicas := 1

fabricCa := &hlfv1alpha1.FabricCA{
TypeMeta: NewTypeMeta("FabricCA"),
Expand All @@ -227,7 +229,7 @@ func randomFabricCA(releaseName string, namespace string) *hlfv1alpha1.FabricCA
Namespace: namespace,
},
Spec: hlfv1alpha1.FabricCASpec{

Replicas: &replicas,
Istio: &hlfv1alpha1.FabricIstio{
Hosts: []string{},
},
Expand Down Expand Up @@ -808,14 +810,15 @@ var _ = Describe("Fabric Controllers", func() {
Expect(err).ToNot(HaveOccurred())
k8sIP, err := utils.GetPublicIPKubernetes(ClientSet)
Expect(err).ToNot(HaveOccurred())

replicas := 1
fabricCa := &hlfv1alpha1.FabricCA{
TypeMeta: NewTypeMeta("FabricCA"),
ObjectMeta: v1.ObjectMeta{
Name: objName,
Namespace: FabricNamespace,
},
Spec: hlfv1alpha1.FabricCASpec{
Replicas: &replicas,
Istio: &hlfv1alpha1.FabricIstio{
Hosts: []string{},
},
Expand Down
2 changes: 2 additions & 0 deletions kubectl-hlf/cmd/ca/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func (c *createCmd) run(_ []string) error {
if err != nil {
return err
}
replicas := 1
fabricCA := &v1alpha1.FabricCA{
TypeMeta: v1.TypeMeta{
Kind: "FabricCA",
Expand All @@ -140,6 +141,7 @@ func (c *createCmd) run(_ []string) error {
Namespace: c.caOpts.NS,
},
Spec: v1alpha1.FabricCASpec{
Replicas: &replicas,
Database: v1alpha1.FabricCADatabase{
Type: c.caOpts.DBType,
Datasource: c.caOpts.DBDataSource,
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/hlf.kungfusoftware.es/v1alpha1/hlf_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,11 @@ type FabricCASpec struct {
// +optional
// +kubebuilder:validation:Default={}
Env []corev1.EnvVar `json:"env"`

// +kubebuilder:default:=1
// +optional
// +nullable
Replicas *int `json:"replicas"`
}

type FabricCATLSConf struct {
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/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.