Certainly! Below is the combined and updated YAML configuration file that includes the ConfigMap, Deployments, and Services for both the RADIUS generator and processor. This setup is designed to process RADIUS requests and return them with an added custom attribute as you described.


---
apiVersion: v1
kind: Namespace
metadata:
  name: lms

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: radius-config
  namespace: lms
data:
  default: |
    server default {
      listen {
        type = auth
        ipaddr = *
        port = 1812
      }
      authorize {
        update request {
          Example-Custom-Attribute = "Added by processor"
        }
        files
        pap
      }
      authenticate {
        Auth-Type PAP {
          pap
        }
      }
      post-auth {
        update reply {
          Reply-Message += "%{Example-Custom-Attribute}"
        }
        exec
      }
    }
  generator-script: |
    #!/bin/bash
    while true; do
      echo -e "User-Name=user$RANDOM\nUser-Password=pass$RANDOM\nCalling-Station-Id=00:11:22:33:44:$RANDOM" | <br/>      radclient -f /tmp/custom_dictionary -t 1 -x 10.7.13.199:1812 auth testing123
      sleep 5
    done
  custom_dictionary: |
    VENDOR      Example                 54321
    BEGIN-VENDOR Example
      ATTRIBUTE   Example-Custom-Attribute     1   string
    END-VENDOR   Example
    $INCLUDE /etc/raddb/dictionary

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: radius-generator
  namespace: lms
spec:
  replicas: 1
  selector:
    matchLabels:
      app: radius-generator
  template:
    metadata:
      labels:
        app: radius-generator
    spec:
      containers:
      - name: radius-generator
        image: git.pyxis.com.tn:5000/radius/freeradius:1.0
        command: ["/bin/bash"]
        args:
          - "-c"
          - >
            cp /config/generator-script /tmp/generate.sh &&
            cp /config/custom_dictionary /tmp/custom_dictionary &&
            chmod +x /tmp/generate.sh &&
            /tmp/generate.sh
        volumeMounts:
        - name: config-volume
          mountPath: /config
      volumes:
      - name: config-volume
        configMap:
          name: radius-config
          items:
          - key: generator-script
            path: generator-script
          - key: custom_dictionary
            path: custom_dictionary

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: radius-processor
  namespace: lms
spec:
  replicas: 1
  selector:
    matchLabels:
      app: radius-processor
  template:
    metadata:
      labels:
        app: radius-processor
    spec:
      containers:
      - name: radius-processor
        image: git.pyxis.com.tn:5000/radius/freeradius:1.0
        command: ["/usr/sbin/freeradius"]
        args: ["-X", "-f"]
        ports:
        - containerPort: 1812
          protocol: UDP
        volumeMounts:
        - name: config-volume
          mountPath: /etc/raddb/sites-enabled/default
          subPath: default
        - name: dictionary-volume
          mountPath: /etc/raddb/dictionary.example
          subPath: custom_dictionary
      volumes:
      - name: config-volume
        configMap:
          name: radius-config
          items:
          - key: default
            path: default
      - name: dictionary-volume
        configMap:
          name: radius-config
          items:
          - key: custom_dictionary
            path: custom_dictionary

---
apiVersion: v1
kind: Service
metadata:
  name: radius-generator-service
  namespace: lms
spec:
  selector:
    app: radius-generator
  ports:
  - port: 1812
    protocol: UDP
    targetPort: 1812

---
apiVersion: v1
kind: Service
metadata:
  name: radius-processor-service
  namespace: lms
spec:
  selector:
    app: radius-processor
  ports:
  - port: 1812
    protocol: UDP
    targetPort: 1812
  externalIPs:
  - 10.7.13.199
  - 10.7.13.201
  - 10.7.13.202


### Explanation and Notes

Namespace:
- Included the lms namespace to ensure all resources are created within the same namespace.

ConfigMap (radius-config):
- default: Contains the FreeRADIUS server configuration, which updates the request with Example-Custom-Attribute and appends it to the Reply-Message.
- generator-script: Bash script that sends RADIUS authentication requests to the processor.
- Uses -e with echo to interpret newline characters (\n).
- Sends requests to 10.7.13.199:1812, one of the external IPs.
- custom_dictionary: Defines the custom attribute Example-Custom-Attribute for both the generator and processor.

Deployment (radius-generator):
- Copies generator-script and custom_dictionary from the ConfigMap to /tmp.
- Makes generate.sh executable and runs it.
- Volume mounts:
- Mounts /config to access the script and dictionary.

Deployment (radius-processor):
- Runs FreeRADIUS in debug mode (-X) and stays in the foreground (-f).
- Volume mounts:
- Mounts default configuration to /etc/raddb/sites-enabled/default.
- Mounts custom_dictionary to /etc/raddb/dictionary.example.
- It's important that FreeRADIUS includes this dictionary. The custom_dictionary includes the line $INCLUDE /etc/raddb/dictionary to ensure all standard attributes are recognized.
- Ports:
- Exposes UDP port 1812 for RADIUS authentication.

Services:
- radius-generator-service: Though not strictly necessary for this setup (since the generator initiates outbound connections), it's included for completeness.
- radius-processor-service:
- Exposes UDP port 1812.
- Has externalIPs set to 10.7.13.199, 10.7.13.201, and 10.7.13.202 as specified.

### Additional Considerations

- Custom Dictionary Inclusion:
- The custom dictionary is mounted as /etc/raddb/dictionary.example.
- Ensure that FreeRADIUS includes this dictionary. Since FreeRADIUS automatically includes all dictionaries in /etc/raddb, this should work, but you may need to modify the main dictionary file or include the custom dictionary in your configuration.

- FreeRADIUS Configuration (default):
- The authorize section adds the custom attribute to the request.
- The post-auth section adds the custom attribute to the reply message.
- This ensures that when the generator receives the response, it includes the Example-Custom-Attribute.

- Generator Script Adjustments:
- Uses -e with echo to handle newlines correctly.
- Points to the custom dictionary at /tmp/custom_dictionary using the -f option with radclient.
- Sends requests every 5 seconds.

- Testing and Verification:
- After applying this configuration, monitor the logs:
- Generator Pod: Should show the requests being sent and any responses received, including the Reply-Message.
- Processor Pod: Running in debug mode (-X), it will output detailed logs of the requests and responses, which can help verify that the custom attribute is being processed correctly.
- Use kubectl logs to access the logs of the pods.

- Load Distribution (Optional):
- If you wish to distribute traffic across all three external IPs, you can modify the generator script to randomly select one of the IPs:

    #!/bin/bash
    IPS=("10.7.13.199" "10.7.13.201" "10.7.13.202")
    while true; do
      IP=${IPS[$RANDOM % ${#IPS[@]}]}
      echo -e "User-Name=user$RANDOM\nUser-Password=pass$RANDOM\nCalling-Station-Id=00:11:22:33:44:$RANDOM" | <br/>      radclient -f /tmp/custom_dictionary -t 1 -x $IP:1812 auth testing123
      sleep 5
    done

  - Update the generator-script in the ConfigMap accordingly.

### Applying the Configuration

1. Save the YAML file to a file, e.g., radius-setup.yaml.

2. Apply the configuration:

   kubectl apply -f radius-setup.yaml


3. Verify the resources:

   kubectl get all -n lms


4. Check the logs to ensure everything is running smoothly:

   kubectl logs -n lms deployment/radius-generator
   kubectl logs -n lms deployment/radius-processor


### Conclusion

This combined YAML file provides a complete setup for your RADIUS processing needs. It defines all necessary Kubernetes resources and ensures that the generator and processor interact as intended, with the processor adding the custom attribute to each RADIUS response.

Feel free to modify the configurations as needed for your specific environment or requirements. If you encounter any issues or have further questions, don't hesitate to ask!
-recreate full corected compleetc combined yml and that only the processeur add the custom attributes and i want it to be dynamic and he return response to generatot and use service and external ips for return if possible